CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Guest

    Bitmap, 5 or 6 bits for Green

    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


  2. #2
    Join Date
    Apr 1999
    Posts
    53

    Re: Bitmap, 5 or 6 bits for Green

    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.


  3. #3
    Guest

    Re: Bitmap, 5 or 6 bits for Green

    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.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured