• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ FreeImage_OpenMemory函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中FreeImage_OpenMemory函数的典型用法代码示例。如果您正苦于以下问题:C++ FreeImage_OpenMemory函数的具体用法?C++ FreeImage_OpenMemory怎么用?C++ FreeImage_OpenMemory使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了FreeImage_OpenMemory函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: sendFullFrame

// Transmits an entire frame of imagery to the client
int sendFullFrame(SOCKET &clientSocket) {
	int status = 0;
	FIBITMAP *fiImage;
	FIMEMORY *fiBuffer;

	// Signal that a new frame is required and wait for frame
	InterlockedExchange( &g_lRequestFlag, TRUE );
	g_pRequestEvent->waitFor();
	
	// Enter critical section for frame buffer from UT2004
	// and copy new raw image to local buffer
	EnterCriticalSection( &g_CriticalSection );
	{
		fiImage = FreeImage_ConvertTo24Bits(g_fiImage);
	} 
	LeaveCriticalSection( &g_CriticalSection );

	// Create memory reference
	fiBuffer = FreeImage_OpenMemory();

	// Convert a raw frame to a useful image
	status = writeFrame( fiBuffer, fiImage, g_iImageType );
	if (status != 1) status = 0; // TODO: handle error here
	
	// Transmit frame over socket
	status = transmitFrame( fiBuffer, clientSocket, g_iImageType );

	// Delete memory references
	FreeImage_Unload( fiImage );
	FreeImage_CloseMemory( fiBuffer );

	return status;
}
开发者ID:adesproject,项目名称:ADES,代码行数:34,代码来源:server.cpp


示例2: SDL_assert_release

FIBITMAP *GraphicsHelps::loadImageRC(const char *file)
{
    unsigned char *memory = nullptr;
    size_t fileSize = 0;
    SDL_assert_release(RES_getMem(file, memory, fileSize));
    //{
        //pLogCritical("Resource file \"%s\" is not found!", file);
        //return nullptr;
    //}

    FIMEMORY *imgMEM = FreeImage_OpenMemory(memory, static_cast<FI_DWORD>(fileSize));
    FREE_IMAGE_FORMAT formato = FreeImage_GetFileTypeFromMemory(imgMEM);

    if(formato == FIF_UNKNOWN)
        return nullptr;

    FIBITMAP *img = FreeImage_LoadFromMemory(formato, imgMEM, 0);
    FreeImage_CloseMemory(imgMEM);

    if(!img)
        return nullptr;

    FIBITMAP *temp;
    temp = FreeImage_ConvertTo32Bits(img);

    if(!temp)
        return nullptr;

    FreeImage_Unload(img);
    img = temp;
    return img;
}
开发者ID:jpmac26,项目名称:PGE-Project,代码行数:32,代码来源:graphics_funcs.cpp


示例3: FreeImage_SetOutputMessage

    //---------------------------------------------------------------------
    DataStreamPtr FreeImageCodec::code(MemoryDataStreamPtr& input, Codec::CodecDataPtr& pData) const
    {        
		// Set error handler
		FreeImage_SetOutputMessage(FreeImageSaveErrorHandler);

		FIBITMAP* fiBitmap = encode(input, pData);

		// open memory chunk allocated by FreeImage
		FIMEMORY* mem = FreeImage_OpenMemory();
		// write data into memory
		FreeImage_SaveToMemory((FREE_IMAGE_FORMAT)mFreeImageType, fiBitmap, mem);
		// Grab data information
		BYTE* data;
		DWORD size;
		FreeImage_AcquireMemory(mem, &data, &size);
		// Copy data into our own buffer
		// Because we're asking MemoryDataStream to free this, must create in a compatible way
		BYTE* ourData = OGRE_ALLOC_T(BYTE, size, MEMCATEGORY_GENERAL);
		memcpy(ourData, data, size);
		// Wrap data in stream, tell it to free on close 
		DataStreamPtr outstream(OGRE_NEW MemoryDataStream(ourData, size, true));
		// Now free FreeImage memory buffers
		FreeImage_CloseMemory(mem);
		// Unload bitmap
		FreeImage_Unload(fiBitmap);

		return outstream;


    }
开发者ID:LiberatorUSA,项目名称:GUCE,代码行数:31,代码来源:OgreFreeImageCodec.cpp


示例4: encode

    //---------------------------------------------------------------------
    DataStreamPtr FreeImageCodec::code(MemoryDataStreamPtr& input, Codec::CodecDataPtr& pData) const
    {        
		FIBITMAP* fiBitmap = encode(input, pData);

		// open memory chunk allocated by FreeImage
		FIMEMORY* mem = FreeImage_OpenMemory();
		// write data into memory
		FreeImage_SaveToMemory((FREE_IMAGE_FORMAT)mFreeImageType, fiBitmap, mem);
		// Grab data information
		BYTE* data;
		DWORD size;
		FreeImage_AcquireMemory(mem, &data, &size);
		// Copy data into our own buffer
		BYTE* ourData = new BYTE[size];
		memcpy(ourData, data, size);
		// Wrap data in stream, tell it to free on close 
		DataStreamPtr outstream(new MemoryDataStream(ourData, size, true));
		// Now free FreeImage memory buffers
		FreeImage_CloseMemory(mem);
		// Unload bitmap
		FreeImage_Unload(fiBitmap);

		return outstream;


    }
开发者ID:andyhebear,项目名称:likeleon,代码行数:27,代码来源:OgreFreeImageCodec.cpp


示例5: FreeImage_SavePageToBlock

static BlockReference* 
FreeImage_SavePageToBlock(MULTIBITMAPHEADER *header, FIBITMAP *data) {
	if (header->read_only || !header->locked_pages.empty())
		return NULL;

	DWORD compressed_size = 0;
	BYTE *compressed_data = NULL;

	// compress the bitmap data

	// open a memory handle
	FIMEMORY *hmem = FreeImage_OpenMemory();
	if(hmem==NULL) return NULL;
	// save the file to memory
	if(!FreeImage_SaveToMemory(header->cache_fif, data, hmem, 0)) {
		FreeImage_CloseMemory(hmem);
		return NULL;
	}
	// get the buffer from the memory stream
	if(!FreeImage_AcquireMemory(hmem, &compressed_data, &compressed_size)) {
		FreeImage_CloseMemory(hmem);
		return NULL;
	}

	// write the compressed data to the cache
	int ref = header->m_cachefile->writeFile(compressed_data, compressed_size);
	// get rid of the compressed data
	FreeImage_CloseMemory(hmem);

	return new(std::nothrow) BlockReference(ref, compressed_size);
}
开发者ID:0xmono,项目名称:miranda-ng,代码行数:31,代码来源:MultiPage.cpp


示例6: gif2png_bufopen

// 独立函数,读取gif图片,写白背景,转为PNG并写入缓存,返回缓存地址
FOX_DLL FIMEMORY * gif2png_bufopen(char *gifpath, BYTE ** buffpointeraddr, DWORD * bufflenaddr)
{
	FIBITMAP * hImage ;
	RGBQUAD * pal ;
	FIMEMORY * hMemory = NULL ;
	BYTE *mem_buffer = NULL ;
	DWORD size_in_bytes = 0 ;

	hImage = FreeImage_Load(FIF_GIF, gifpath, 0);

	pal = FreeImage_GetPalette(hImage);
	pal[70].rgbRed = 255 ;
	pal[70].rgbGreen = 255 ;
	pal[70].rgbBlue = 255 ;
	FreeImage_SetTransparent(hImage, false);

	hMemory = FreeImage_OpenMemory() ;
	FreeImage_SaveToMemory(FIF_PNG, hImage, hMemory, PNG_DEFAULT) ;
	FreeImage_Unload(hImage) ;

	FreeImage_AcquireMemory(hMemory, &mem_buffer, &size_in_bytes);
	*buffpointeraddr = mem_buffer ;
	*bufflenaddr = size_in_bytes ;
	
	return hMemory ;
//	FreeImage_CloseMemory(hMemory) ; // 使用完缓存记得要释放
}
开发者ID:linpinger,项目名称:foxbook-ahk,代码行数:28,代码来源:imgsplit_V1.8.3.cpp


示例7: testAcquireMemIO

void testAcquireMemIO(const char *lpszPathName) {
    FIMEMORY *hmem = NULL;

    // load a regular file
    FREE_IMAGE_FORMAT fif = FreeImage_GetFileType(lpszPathName);
    FIBITMAP *dib = FreeImage_Load(fif, lpszPathName, 0);

    // open and allocate a memory stream
    hmem = FreeImage_OpenMemory();

    // save the file to memory
    FreeImage_SaveToMemory(FIF_PNG, dib, hmem, PNG_DEFAULT);

    FreeImage_Unload(dib);

    // get the buffer from the memory stream
    BYTE *mem_buffer = NULL;
    DWORD size_in_bytes = 0;

    FreeImage_AcquireMemory(hmem, &mem_buffer, &size_in_bytes);

    // save the buffer in a file stream
    FILE *stream = fopen("buffer.png", "wb");
    if(stream) {
        fwrite(mem_buffer, sizeof(BYTE), size_in_bytes, stream);
        fclose(stream);
    }

    // close and free the memory stream
    FreeImage_CloseMemory(hmem);

}
开发者ID:ConnorShore,项目名称:Game,代码行数:32,代码来源:testMemIO.cpp


示例8: FreeImage_GetFIFFromFilename

unsigned char * HVSTGFX::loadImageFile(CFileData *image, HVSTGFX::IMAGEFILE *imgFile, GLuint &texture)
{
	FREE_IMAGE_FORMAT fif = FreeImage_GetFIFFromFilename(image->getName().c_str());
	FIMEMORY * stream = 0;
	unsigned char tempRGB;
	GLuint tempTex = 0;
	GLenum errCode;
	bool error = false;

	stream = FreeImage_OpenMemory(image->getData());

	if(FreeImage_FIFSupportsReading(fif))
	imgFile->dib = FreeImage_LoadFromMemory(fif, stream);

	if(!imgFile->dib)
	{
		glbl->debugger->writeString("failed to open sprite " + image->getName());
		return NULL;
	}

	//pointer to image data
	unsigned char* bits;

	bits = FreeImage_GetBits(imgFile->dib);
	imgFile->width = FreeImage_GetWidth(imgFile->dib); imgFile->height = FreeImage_GetHeight(imgFile->dib);
	imgFile->size = sizeof(bits);
	int size = imgFile->width*imgFile->height;//(FreeImage_GetWidth(dib) * FreeImage_GetHeight(dib));

	for (int imageIDx = 0; imageIDx < size * 4; imageIDx += 4)
	{
		tempRGB = bits[imageIDx];
		bits[imageIDx] = bits[imageIDx + 2];
		bits[imageIDx + 2] = tempRGB;
	}
	
	glGenTextures(1, &tempTex);
	texture = tempTex;
	
	errCode = glGetError();
	if (errCode != GL_NO_ERROR)
	{
		MessageBox(NULL, _T("Unable to detect OpenGL support. Check if you have your graphics driver installed, or if your graphics card supports OpenGL."), NULL, NULL);
	}
	glBindTexture(GL_TEXTURE_2D, texture);
	
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
	glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, imgFile->width, imgFile->height, 0, GL_RGBA, GL_UNSIGNED_BYTE, bits);
	
	//FreeImage_Unload(dib);
	
#ifdef _DEBUG
	if (!error)
		glbl->debugger->writeString("successfully loaded sprite " + image->getName() + "\n");
#endif
	return bits;

}
开发者ID:MGZero,项目名称:Harvest,代码行数:58,代码来源:glMain.cpp


示例9: textureFromBytes

Ogre::TexturePtr textureFromBytes(const QByteArray &ba,
                                  const std::string &name) {

  static bool fi_init = false;
  if (!fi_init) {
    FreeImage_Initialise();
  }

  void *data = const_cast<char *>(ba.data());
  FIMEMORY *mem =
      FreeImage_OpenMemory(reinterpret_cast<BYTE *>(data), ba.size());
  FREE_IMAGE_FORMAT fif = FreeImage_GetFileTypeFromMemory(mem, 0);
  if (fif == FIF_UNKNOWN) {
    FreeImage_CloseMemory(mem);
    throw std::runtime_error("Image format is not supported for loading");
  }
  FIBITMAP *bmp = FreeImage_LoadFromMemory(fif, mem, 0);
  FreeImage_CloseMemory(mem);
  if (!bmp) {
    throw std::runtime_error("Failed to decode image");
  }
  FIBITMAP *converted = FreeImage_ConvertTo24Bits(bmp);
  FreeImage_Unload(bmp);
  if (!converted) {
    throw std::runtime_error("Failed to convert image to 24 bit");
  }

  const unsigned w = FreeImage_GetWidth(converted);
  const unsigned h = FreeImage_GetHeight(converted);
  const unsigned data_size = w * h * 3;
  BYTE *image_data = FreeImage_GetBits(converted);

  ROS_INFO("Loading a %u x %u texture", w, h);

  //  create texture
  Ogre::TexturePtr texture;
  try {
    Ogre::DataStreamPtr data_stream;
    data_stream.bind(new Ogre::MemoryDataStream(image_data, data_size));

    const Ogre::String res_group =
        Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME;
    Ogre::TextureManager &texture_manager =
        Ogre::TextureManager::getSingleton();
    texture =
        texture_manager.loadRawData(name, res_group, data_stream, w, h,
                                    Ogre::PF_R8G8B8, Ogre::TEX_TYPE_2D, 0);
  }
  catch (...) {
    //  clean up FreeImage before re-throwing
    FreeImage_Unload(converted);
    throw;
  }

  return texture;
}
开发者ID:Exchizz,项目名称:rviz_satellite,代码行数:56,代码来源:aerialmap_display.cpp


示例10: isThisFormat

	bool isThisFormat(MemChunk& mc)
	{
		FIMEMORY*         mem = FreeImage_OpenMemory((BYTE*)mc.getData(), mc.getSize());
		FREE_IMAGE_FORMAT fif = FreeImage_GetFileTypeFromMemory(mem, 0);
		FreeImage_CloseMemory(mem);
		if (fif == FIF_UNKNOWN)
			return false;
		else
			return true;
	}
开发者ID:Talon1024,项目名称:SLADE,代码行数:10,代码来源:SIFormat.cpp


示例11: FreeImage_LoadFromMem

FIBITMAP* FreeImage_LoadFromMem(FREE_IMAGE_FORMAT fif, fiio_mem_handle *handle, int flags)
{
	if (handle && handle->data) {
		FIMEMORY *hmem = FreeImage_OpenMemory((BYTE *)handle->data, handle->datalen);
		FREE_IMAGE_FORMAT _fif = (fif != FIF_UNKNOWN) ? fif : FreeImage_GetFileTypeFromMemory(hmem, 0);
		FIBITMAP *dib = FreeImage_LoadFromMemory(_fif, hmem, flags);
		FreeImage_CloseMemory(hmem);
	}

	return NULL;
}
开发者ID:Seldom,项目名称:miranda-ng,代码行数:11,代码来源:main.cpp


示例12: FI

void FI(loadImageFile)(Bitmap& bitmap, Gosu::Reader input)
{
    // Read all available input
    std::vector<BYTE> data(input.resource().size() - input.position());
    input.read(&data[0], data.size());
    FIMEMORY* fim = FreeImage_OpenMemory(&data[0], data.size());
    FREE_IMAGE_FORMAT fif = FreeImage_GetFileTypeFromMemory(fim);
    FIBITMAP* fib = FreeImage_LoadFromMemory(fif, fim, GOSU_FIFLAGS);
    checkForFreeImageErrors(fib != 0);
    fibToBitmap(bitmap, fib, fif);
}
开发者ID:JTunnessen,项目名称:gosu,代码行数:11,代码来源:BitmapFreeImage.cpp


示例13: libraw_LoadEmbeddedPreview

/** 
Get the embedded JPEG preview image from RAW picture with included Exif Data. 
@param RawProcessor Libraw handle
@param flags JPEG load flags
@return Returns the loaded dib if successfull, returns NULL otherwise
*/
static FIBITMAP * 
libraw_LoadEmbeddedPreview(LibRaw *RawProcessor, int flags) {
	FIBITMAP *dib = NULL;
	libraw_processed_image_t *thumb_image = NULL;
	
	try {
		// unpack data
		if(RawProcessor->unpack_thumb() != LIBRAW_SUCCESS) {
			// run silently "LibRaw : failed to run unpack_thumb"
			return NULL;
		}

		// retrieve thumb image
		int error_code = 0;
		thumb_image = RawProcessor->dcraw_make_mem_thumb(&error_code);
		if(thumb_image) {
			if(thumb_image->type != LIBRAW_IMAGE_BITMAP) {
				// attach the binary data to a memory stream
				FIMEMORY *hmem = FreeImage_OpenMemory((BYTE*)thumb_image->data, (DWORD)thumb_image->data_size);
				// get the file type
				FREE_IMAGE_FORMAT fif = FreeImage_GetFileTypeFromMemory(hmem, 0);
				if(fif == FIF_JPEG) {
					// rotate according to Exif orientation
					flags |= JPEG_EXIFROTATE;
				}
				// load an image from the memory stream
				dib = FreeImage_LoadFromMemory(fif, hmem, flags);
				// close the stream
				FreeImage_CloseMemory(hmem);
			} else if((flags & FIF_LOAD_NOPIXELS) != FIF_LOAD_NOPIXELS) {
				// convert processed data to output dib
				dib = libraw_ConvertProcessedImageToDib(thumb_image);
			}
		} else {
			throw "LibRaw : failed to run dcraw_make_mem_thumb";
		}

		// clean-up and return
		RawProcessor->dcraw_clear_mem(thumb_image);

		return dib;

	} catch(const char *text) {
		// clean-up and return
		if(thumb_image) {
			RawProcessor->dcraw_clear_mem(thumb_image);
		}
		if(text != NULL) {
			FreeImage_OutputMessageProc(s_format_id, text);
		}
	}

	return NULL;
}
开发者ID:TLeonardUK,项目名称:MicroBuild,代码行数:60,代码来源:PluginRAW.cpp


示例14: switch

int CPropertiesFiles::previewWndProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) {
	static bool fDowned=false;

	switch (uMsg) {
		case WM_INITDIALOG:
			if (!fiBitmap) {
				FIMEMORY* fiMemory=FreeImage_OpenMemory((BYTE*)lParam,bitmapInfo->unc_size);
				RECT rect;
				POINT pt={0,0};

				if (fiBitmap=FreeImage_LoadFromMemory(_tcsicmp(bitmapInfo->name+_tcslen(bitmapInfo->name)-4,".tga")?_tcsicmp(bitmapInfo->name+_tcslen(bitmapInfo->name)-4,".bmp")?FIF_JPEG:FIF_BMP:FIF_TARGA,fiMemory)) {
					::GetWindowRect(hwndDlg,&rect);
					::ClientToScreen(hwndDlg,&pt);
					rect.right=FreeImage_GetWidth(fiBitmap)+(pt.x-rect.left);
					rect.bottom=FreeImage_GetHeight(fiBitmap)+(pt
						.y-rect.top);;
					::MoveWindow(hwndDlg,rect.left,rect.top,rect.right,rect.bottom,FALSE);
					FreeImage_CloseMemory(fiMemory);

					::SetWindowText(hwndDlg,_tcsrchr(bitmapInfo->name,'/')+1);
					fDowned=false;
				} else {
					fDowned=true;
					::EndDialog(hwndDlg,0);
				}
			}
			break;
		case WM_LBUTTONDOWN:
		case WM_RBUTTONDOWN:
			fDowned=true;
			break;
		case WM_CLOSE:
			fDowned=true;
		case WM_LBUTTONUP:
		case WM_RBUTTONUP:
			if (fDowned) {
				FreeImage_Unload(fiBitmap);
				fiBitmap=NULL;
				::EndDialog(hwndDlg,0);
			}
			break;
		case WM_PAINT:
			{
				HDC hDC=::GetDC(hwndDlg);
				::SetStretchBltMode(hDC, COLORONCOLOR);
				::StretchDIBits(hDC, 0,0,FreeImage_GetWidth(fiBitmap), FreeImage_GetHeight(fiBitmap), 
					0, 0, FreeImage_GetWidth(fiBitmap), FreeImage_GetHeight(fiBitmap),
					FreeImage_GetBits(fiBitmap), FreeImage_GetInfo(fiBitmap), DIB_RGB_COLORS, SRCCOPY);
				::ReleaseDC(hwndDlg,hDC);
			}
	}
	return FALSE;
}
开发者ID:v998,项目名称:studiokuma,代码行数:53,代码来源:PropertiesFiles.cpp


示例15: FreeImage_OpenMemory

void TextureManager::loadTexture2DMem(unsigned char* imageData,long length) {
    FIMEMORY* hmem = FreeImage_OpenMemory(imageData,length);
    FREE_IMAGE_FORMAT fif = FreeImage_GetFileTypeFromMemory(hmem);
    FIBITMAP* image = FreeImage_LoadFromMemory(fif, hmem, 0);

    FIBITMAP* temp = image;
    image = FreeImage_ConvertTo32Bits(image);
    FreeImage_Unload(temp);
    FreeImage_CloseMemory(hmem);

    int w = FreeImage_GetWidth(image);
    int h = FreeImage_GetHeight(image);


    printf("[Texture Manager] Image loaded from memory, is %d x %d\n",w,h);

    GLubyte* textureBytes = new GLubyte[4*w*h];
    char* pixels = (char*)FreeImage_GetBits(image);

    //FreeImage loads in BGR format, so we need to swap some bytes(Or use GL_BGR)

    for(int j= 0; j<w*h; j++) {
        textureBytes[j*4+0]= pixels[j*4+2];
        textureBytes[j*4+1]= pixels[j*4+1];
        textureBytes[j*4+2]= pixels[j*4+0];
        textureBytes[j*4+3]= pixels[j*4+3];
    }


    glGenTextures(1, &(textInt));

    glBindTexture(GL_TEXTURE_2D, textInt);
    glTexImage2D(GL_TEXTURE_2D,0,GL_RGBA, w, h, 0, GL_RGBA,GL_UNSIGNED_BYTE,(GLvoid*)textureBytes );



    Textures.push_back(textInt);


    glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST );
    glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST );
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);


    GLenum errorLoading = glGetError();
    if(errorLoading) {
        cout<<"There was an error loading the texture: "<<errorLoading<<endl;
    }


}
开发者ID:johnkussack,项目名称:gleech,代码行数:52,代码来源:TextureManager.cpp


示例16: FreeImage_UnlockPage

void DLL_CALLCONV
FreeImage_UnlockPage(FIMULTIBITMAP *bitmap, FIBITMAP *page, BOOL changed) {
	if ((bitmap) && (page)) {
		MULTIBITMAPHEADER *header = FreeImage_GetMultiBitmapHeader(bitmap);

		// find out if the page we try to unlock is actually locked...

		if (header->locked_pages.find(page) != header->locked_pages.end()) {
			// store the bitmap compressed in the cache for later writing
			
			if (changed && !header->read_only) {
				header->changed = TRUE;

				// cut loose the block from the rest

				BlockListIterator i = FreeImage_FindBlock(bitmap, header->locked_pages[page]);

				// compress the data

				DWORD compressed_size = 0;
				BYTE *compressed_data = NULL;

				// open a memory handle
				FIMEMORY *hmem = FreeImage_OpenMemory();
				// save the page to memory
				FreeImage_SaveToMemory(header->cache_fif, page, hmem, 0);
				// get the buffer from the memory stream
				FreeImage_AcquireMemory(hmem, &compressed_data, &compressed_size);

				// write the data to the cache
				
				if (i->m_type == BLOCK_REFERENCE) {
					header->m_cachefile.deleteFile(i->getReference());
				}
				
				int iPage = header->m_cachefile.writeFile(compressed_data, compressed_size);
				
				*i = PageBlock(BLOCK_REFERENCE, iPage, compressed_size);
				
				// get rid of the compressed data

				FreeImage_CloseMemory(hmem);
			}

			// reset the locked page so that another page can be locked

			FreeImage_Unload(page);

			header->locked_pages.erase(page);
		}
	}
}
开发者ID:miranda-ng,项目名称:miranda-ng,代码行数:52,代码来源:MultiPage.cpp


示例17: FreeImage_SaveToMem

FIMEMORY* FreeImage_SaveToMem(FREE_IMAGE_FORMAT fif, FIBITMAP *dib, fiio_mem_handle *handle, int flags)
{
	if (handle) {
		FIMEMORY *hmem = FreeImage_OpenMemory(NULL, 0);
		if(fif == FIF_UNKNOWN)
			fif = FIF_BMP;
		handle->curpos = 0;
		FreeImage_SaveToMemory(fif, dib, hmem, flags);
		FreeImage_AcquireMemory(hmem, (BYTE **)&handle->data, (DWORD *)&handle->datalen);
		return hmem;
	}
	return NULL;
}
开发者ID:Seldom,项目名称:miranda-ng,代码行数:13,代码来源:main.cpp


示例18: printf

//----------------------------------------------------
bool ofImage::loadImageFromMemory(const ofBuffer & buffer, ofPixels &pix){

	int					width, height, bpp;
	bool bLoaded		= false;
	FIBITMAP * bmp		= NULL;
	FIMEMORY *hmem		= NULL;
	
	printf("loadImageFromMemory\n");

	hmem = FreeImage_OpenMemory((unsigned char*)buffer.getBuffer(), buffer.size());
	if (hmem == NULL){
		ofLog(OF_LOG_ERROR,"couldn't create memory handle! \n");
		return false;
	}

	//get the file type!
	FREE_IMAGE_FORMAT fif = FreeImage_GetFileTypeFromMemory(hmem);
	if( fif == -1 ){
		ofLog(OF_LOG_ERROR,"unable to guess format", fif);
		return false;
		FreeImage_CloseMemory(hmem);
	}


	//make the image!!
	bmp = FreeImage_LoadFromMemory(fif, hmem, 0);
	
	if( bmp != NULL ){
		bLoaded = true;
		ofLog(OF_LOG_VERBOSE,"FreeImage_LoadFromMemory worked!\n");
	}
	
	//-----------------------------

	if (bLoaded){
		putBmpIntoPixels(bmp,pix);
	} else {
		width = height = bpp = 0;
	}

	if (bmp != NULL){
		FreeImage_Unload(bmp);
	}
	
	if( hmem != NULL ){
		FreeImage_CloseMemory(hmem);
	}

	return bLoaded;
}
开发者ID:emonty,项目名称:openFrameworks,代码行数:51,代码来源:ofImage.cpp


示例19: loadImage

static bool loadImage(ofPixels_<PixelType> & pix, const ofBuffer & buffer, const ofImageLoadSettings &settings){
	ofInitFreeImage();
	bool bLoaded = false;
	FIBITMAP* bmp = nullptr;
	FIMEMORY* hmem = nullptr;
	
	hmem = FreeImage_OpenMemory((unsigned char*) buffer.getData(), buffer.size());
	if (hmem == nullptr){
		ofLogError("ofImage") << "loadImage(): couldn't load image from ofBuffer, opening FreeImage memory failed";
		return false;
	}

	//get the file type!
	FREE_IMAGE_FORMAT fif = FreeImage_GetFileTypeFromMemory(hmem);
	if( fif == -1 ){
		ofLogError("ofImage") << "loadImage(): couldn't load image from ofBuffer, unable to guess image format from memory";
		FreeImage_CloseMemory(hmem);
		return false;
	}


	//make the image!!
	if(fif == FIF_JPEG) {
		int option = getJpegOptionFromImageLoadSetting(settings);
		bmp = FreeImage_LoadFromMemory(fif, hmem, option);
	} else {
		bmp = FreeImage_LoadFromMemory(fif, hmem, 0);
	}
	
	if( bmp != nullptr ){
		bLoaded = true;
	}
	
	//-----------------------------
	
	if (bLoaded){
		putBmpIntoPixels(bmp,pix);
	}

	if (bmp != nullptr){
		FreeImage_Unload(bmp);
	}
	
	if( hmem != nullptr ){
		FreeImage_CloseMemory(hmem);
	}

	return bLoaded;
}
开发者ID:BaptisteTheoriz,项目名称:openFrameworks,代码行数:49,代码来源:ofImage.cpp


示例20: FreeImage_InsertPage

void DLL_CALLCONV
FreeImage_InsertPage(FIMULTIBITMAP *bitmap, int page, FIBITMAP *data) {
	if ((bitmap) && (data)) {
		if (page < FreeImage_GetPageCount(bitmap)) {
			MULTIBITMAPHEADER *header = FreeImage_GetMultiBitmapHeader(bitmap);

			if ((!header->read_only) && (header->locked_pages.empty())) {
				DWORD compressed_size = 0;
				BYTE *compressed_data = NULL;

				// compress the bitmap data

				// open a memory handle
				FIMEMORY *hmem = FreeImage_OpenMemory();
				// save the file to memory
				FreeImage_SaveToMemory(header->cache_fif, data, hmem, 0);
				// get the buffer from the memory stream
				FreeImage_AcquireMemory(hmem, &compressed_data, &compressed_size);

				// write the compressed data to the cache

				int ref = header->m_cachefile->writeFile(compressed_data, compressed_size);

				// add a block

				if (page > 0) {
					BlockListIterator block_source = FreeImage_FindBlock(bitmap, page);

					BlockReference *block = new BlockReference(ref, compressed_size);

					header->m_blocks.insert(block_source, (BlockTypeS *)block);
				} else {
					BlockReference *block = new BlockReference(ref, compressed_size);

					header->m_blocks.push_front((BlockTypeS *)block);
				}

				// get rid of the compressed buffer

				FreeImage_CloseMemory(hmem);

				header->changed = TRUE;
				header->page_count = -1;
			}
		}
	}
}
开发者ID:barsnadcat,项目名称:steelandconcrete,代码行数:47,代码来源:MultiPage.cpp



注:本文中的FreeImage_OpenMemory函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ FreeImage_OutputMessageProc函数代码示例发布时间:2022-05-30
下一篇:
C++ FreeImage_Load函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap