The PNG images that were problematic were using indexed color modes and the raw pixel data was indeed being returned as 8bpp. The correct course of action was to treat this data as 8 bits per pixel, and treat each 8-bit value as an index into a palette of colors that can be retrieved using FreeImage_GetPalette
. The alternative, which is the choice I ultimately made, was to call FreeImage_ConvertTo32Bits
on these indexed color mode PNG images, and then pass everything through the same code path as the same 32-bit image format.
Pretty simple conversion, but here it is:
// Convert non-32 bit images
if ( FreeImage_GetBPP( hImage ) != 32 )
{
FIBITMAP* hOldImage = hImage;
hImage = FreeImage_ConvertTo32Bits( hOldImage );
FreeImage_Unload( hOldImage );
}