Jump to content
  • Advertisement
Sign in to follow this  
GMA965_X3100

FreeImage Issue

This topic is 2661 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
Advertisement
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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!