Sign in to follow this  

FreeImage Issue

This topic is 2445 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I fixed the image lading error, never mind.
What i realized, was that in my image loader, bpp, pr bit depth was wrong.
When I modified img loading code to a .png loader instead from .bmp loader,
forgot to change the GL_RGB bit in glTexImage2D ( ) call, to GL_RGBA, which is under .png's bit depth.

I further modified the code, so that it would load any file format, and any file type, while also accouting for change in file type, by changing bit depth in function:

bool generate_bitmap_t ( FREE_IMAGE_FORMAT fileformat, const char *filename, int filetype )
{
FIBITMAP *imgDataPtr;
imgDataPtr = FreeImage_Load ( fileformat, filename, filetype );

int bit_number;

// :-: convert image depth based on filetype
switch ( filetype )
{
case 0 : bit_number = GL_RGB; break; //:-:type 0's are 24bit "rgb"
case 1 : bit_number = GL_RGBA; break; //:-:type 0's are 32bit "rgba"
}

glGenTextures ( 1, &bitmapID );
glBindTexture ( GL_TEXTURE_2D, bitmapID );
glTexImage2D ( GL_TEXTURE_2D, 0, 3, FreeImage_GetWidth ( imgDataPtr ), FreeImage_GetHeight ( imgDataPtr ), 0, bit_number, GL_UNSIGNED_BYTE, FreeImage_GetBits ( imgDataPtr ) );
glTexParameteri ( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
glTexParameteri ( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
return true;
}

[Edited by - GMA965_X3100 on December 29, 2010 2:28:38 AM]

Share this post


Link to post
Share on other sites
Does your code work for pngs?
Im having problems with those. Freeimage reads the png and stores correct rgb values except when theres a transparent color. I read the image data and the 4th bit the alpha is always 0.
When the color is completely transparent the r g and b are 255. What gives its a transparent png file exported from photoshop.

Share this post


Link to post
Share on other sites

This topic is 2445 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this