Question

This is a simple question, but I can't seem to find the answer anywhere in the documentation. I know FreeImage supports 1, 4, 8, 16, 24, and 32+ bit images. But besides that, the documentation mentions that 16 bit images can be in either 555 or 565 format. I would like to know what formats the other image bit depths are stored as? or if the formats are arbitrary, is there a way to retrieve the format dynamically, from the FreeImage library?

Was it helpful?

Solution

It is very easy to determine 555 vs 565 mode in FreeImage:

unsigned red_mask, green_mask, blue_mask;
red_mask = FreeImage_GetRedMask(dib);
green_mask = FreeImage_GetGreenMask(dib);
blue_mask = FreeImage_GetBlueMask(dib);
if (FreeImage_GetBPP(dib) == 16)
{
   if ((red_mask == FI16_565_RED_MASK) && 
       (green_mask == FI16_565_GREEN_MASK) &&
       (blue_mask == FI16_565_BLUE_MASK))
   {
      // We are in RGB16 565 mode
   }
   else
   {
      // We are in RGB16 555 mode
   }
}

And you can always use FreeImage_ConvertTo16Bits555() and FreeImage_ConvertTo16Bits565() functions to convert to the format you desire.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top