create Winapi Bitmaps Manually Using Pixel Arrays

This is a discussion on create Winapi Bitmaps Manually Using Pixel Arrays within the Windows Programming forums, part of the Platform Specific Boards category; Hi. I'm interesting in creating 16/24BPP WinAPI Bitmaps manually for a custom
image file format. My CreateBitmap(...) code works for ...

For a 16 bpp or 32 bpp non-palletized image, the color table must be three entries long; the entries must specify the value of the red, green, and blue (RGB) bitmasks. Because GDI ignores the color table for 24-bpp bitmaps, you should store the image pixels in RGB format.

This doesn't even make sense. 15/16/24/32BPP do not have a palette. I know what bitmasks are -- ie, 11111.000000.00000 = R16 -- but what does that have to do with creating an image?

Any help would be appreciated. Thank you.

Last edited by Salem; 11-05-2006 at 10:56 AM.
Reason: you only need code tags for code, nothing else

> the entries must specify the value of the red, green, and blue (RGB) bitmasks.
Like it says, a 3 entry table
red would be 0xF800
green would be 0x07E0
blue would be 0x001F
correponding to the masks it takes to extract an RGB from each 16-bit number in the pixel data.

What do they mean by "entries"? I assume they are referring to index 1 of the palette[0]. This would correspond to bytes 0-1 (16BPP) or 0-2 (24BPP), but it was not necessary in the 32BPP example I provided, despite the quote from MSDN: "For a 16 bpp or 32 bpp non-palletized image, the color table must be three entries long".

All I'm trying to do is create a HBITMAP from a pixel array in 16/24/32BPP, then access the pixels directly. Anyone know how to do this?

With my DOS 32BIT VESA library, I can easily create/draw/rotate/etc images, but I am not very experienced with Windows API. I use DirectDraw and custom controls/interfaces for all my applications.

Ken - "Please just stick to code tags - the universally applied extra fonts and bold type are overkill" - I use a text preprocessor that automatically formats code to Courier New bold 10, which is standard in 640x480 or 800x600. Sorry if it looks "overkill" *on your PC* or PDA, cell phone, etc.

Salem - "Post your WinAPI version of the code which deals with bitmaps" - The very first example creates a 8x8x32 HBITMAP then displays it.