Advertisement

[FreeImage] Unable to create FIBITMAP * from memory stream

Started by September 20, 2011 10:48 PM
0 comments, last by c-mos 12 years, 1 month ago
I'm trying to create an FIBITMAP from an unsigned char array. I have verified that the data is correct by writing it to a file on the harddrive and opening it with an image viewer. However, for some reason I can't get the bitmap to be created. The memory stream is created, but the bitmap comes out null every time. Here's what I'm working with...

[source]unsigned char * CSpriteX::loadImageFile(CFileData *image, 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)
return NULL;[/source]

The rest of the function should be unneeded. The type of image->getData() is unsigned char * and returns a pointer to the first element of my image data. imgFile->dib is type FIBITMAP *.

EDIT: Disregard this, I fixed it.
Hi, how did you fix the problem ?

regards,
c-mos

This topic is closed to new replies.

Advertisement