Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

FERNANDO-BRASIL

32 and 16-bit BITMAPS

This topic is 5982 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

Hi guys, I''m making a function to read BITMAPS. Until now, everything is OK. The function is working, but only reading 8 and 24-bit bitmaps. Now, I want to code 32-bit BMPs, but I face to a problem. I''m using as reference, a MS WORD tutorial that I got at WotSit webpage. The rules to read a bitmap, as they say, are: "The bitmap has a maximum of 2^32 colors. If the Compression field of the bitmap is set to BI_RGB, the Palette field does not contain any entries. Each dword in the bitmap array represents the relative intensities of blue, green, and red, respectively, for a pixel. The high byte in each dword is not used. If the Compression field of the bitmap is set to BI_BITFIELDS, the Palette field contains three dword color masks that specify the red, green, and blue components, respectively, of each pixel. Each dword in the bitmap array represents a single pixel." What I didn''t figured out, is the BI_BITFIELDS flag. This indicates that we have a pallete with 3 colors. Why do I have these 3 colors? I can''t understand it, because we already have the pixels represented by a DWORD (4 bytes = R, G, B, A) at the BITMAP ARRAY. So, the pallete isn''t necessary! Thank you a lot. Fernando

Share this post


Link to post
Share on other sites
Advertisement
After scanning thru MSDN, I belive that three DWORDs are used to mask out tha R, G and B color values stored in the bitmap array:

"The bmiColors member contains three DWORD color masks which specify the red, green, and blue components, respectively, of each pixel. Bits set in the DWORD mask must be contiguous and should not overlap the bits of another mask. All the bits in the pixel do not have to be used. Each DWORD in the array represents a single pixel."

Another place in MSDN:

"If the biCompression member of the BITMAPINFOHEADER structure is the BI_BITFIELDS value, the bmiColors member of the BITMAPINFO structure contains three doubleword color masks that specify the red, green, and blue components, respectively, of each pixel. Windows 95/98/Me only supports the following color masks for 16 and 32 bits per pixel (bpp).

Value Meaning
16bpp The blue mask is 0x001F, the green mask is 0x03E0, and the red mask is 0x7C00.
16bpp The blue mask is 0x001F, the green mask is 0x07E0, and the red mask is 0xF800.
32bpp The blue mask is 0x000000FF, the green mask is 0x0000FF00, and the red mask is 0x00FF0000. "

I never used such bitmaps, so I cannot help further.

Forever trusting who we are
And nothing else matters
- Metallica

Share this post


Link to post
Share on other sites
Why not let Windows handle it all for you?

HBITMAP hbmImage = (HBITMAP)LoadImage(GetModuleHandle(NULL), bmpfilename, IMAGE_BITMAP, 0, 0, LR_CREATEDIBSECTION | LR_LOADFROMFILE);

Share this post


Link to post
Share on other sites
quote:
Original post by BriTeg
Why not let Windows handle it all for you?

HBITMAP hbmImage = (HBITMAP)LoadImage(GetModuleHandle(NULL), bmpfilename, IMAGE_BITMAP, 0, 0, LR_CREATEDIBSECTION | LR_LOADFROMFILE);




Try this with a bitmap saved by Imaging You''ll have a surprise.



Forever trusting who we are
And nothing else matters
- Metallica

Share this post


Link to post
Share on other sites

  • 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!