Click to See Complete Forum and Search --> : Bitmap, 5 or 6 bits for Green


May 17th, 1999, 01:57 PM
Hi,

I am converting a bitmap (in C++) to put it as a texture in openGL. It works ok on many PC, but on some PC, in 65 536 colors, the texture are not correct.

I know that there are 5 bits for the red and blus colors, but it seems that sometimes, the green takes 6 bits instead of 5. Is there a way to detect when the green color is set to 6 bits? (I use a CBitmap structure). Does it have something to do witn the bmType attribute? I think that the problem occurs before the display in openGL, so in my C++ code.

Thanks in advance for any answers,

David Larochelle

Wes Rogers
May 17th, 1999, 02:32 PM
In 16-bit mode, there are always 5 bits for each color, plus one spare bit, so the texttue problem probably has someting to do with the way your dealing with OpenGL.

May 17th, 1999, 08:14 PM
I seem to recall that from Zafir Anjum's article are rotating a bitmap, there are 555 and 565 "16 bit" formats. I haven't had occasion to investigate this much, but here is an excerpt from Zafir's code (it appears that somewhere (in the bitmapinfoheader?) there may be a 0x7c00 value that is used to distinguish 555 from 565).

case 16:
// Windows95 supports 5 bits each for all colors or 5 bits for red & blue
// and 6 bits for green - Check the color mask for RGB555 or RGB565
if( *((DWORD*)lpvColorTable) == 0x7c00 )
{
// Bitmap is RGB555
m_dwBackColor = ((GetRValue(m_dwBackColor)>>3) << 10) +
((GetGValue(m_dwBackColor)>>3) << 5) +
(GetBValue(m_dwBackColor)>>3);
}
else
{
// Bitmap is RGB565
m_dwBackColor = ((GetRValue(m_dwBackColor)>>3) << 11) +
((GetGValue(m_dwBackColor)>>2) << 5) +
(GetBValue(m_dwBackColor)>>3);
}
break;

I seem to recall that Petzold may have discussed this in Programming Windows.

I hope this helps.