Error loading PCX image in FreeImage library
Posted
by
khanhhh89
on Game Development
See other posts from Game Development
or by khanhhh89
Published on 2013-10-30T10:49:12Z
Indexed on
2013/10/30
16:14 UTC
Read the original article
Hit count: 294
I'm using FreeImage in C++ for loading texuture from the PCX image. My FreeImage code is as following:
FREE_IMAGE_FORMAT fif = FIF_UNKNOWN;
//pointer to the image data
BYTE* bits(0);
fif = FreeImage_GetFileType(m_fileName.c_str(), 0);
if (FreeImage_FIFSupportsReading(fif))
dib = FreeImage_Load(fif, m_fileName.c_str());
//retrieve the image data
bits = FreeImage_GetBits(dib);
//get the image width and height
width = FreeImage_GetWidth(dib);
height = FreeImage_GetHeight(dib);
My problem is the width and height variable are both 512, while the bits array is an empty string, which make the following OPENGL call corrupt:
glTexImage2D(m_textureTarget, 0, GL_RGB, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, bits);
While debugging, I notice that the "fif" variable (which contains the format of the image) is JPEG, while the Image is actually PCX.
I wonder whether or not the FreeImage recognize the wrong format (from PCX to JPEG), so tha the bits array is an empty string.
I hope to see your explanation about this problem. Thanks so much
© Game Development or respective owner