OK, I'm calling LoadImage with the LR_CREATEDIBSECTION to create a device independent bitmap.  What I need to do is to create a palette from the bitmaps color table so I can realize this palette on 256 color devices.  I found a function that will do this in the MSDN dibutil sample, but it requires a BITMAPINFOHEADER structure.  What I need to know, is hot to get the BITMAPINFOHEADER structure give the HBITMAP that I got from LoadImage.
Who is Participating?
chensuConnect With a Mentor Commented:
The following KB article demonstrates how to create a palette from the bitmap loaded with LoadImage.

HOWTO: How To Use LoadImage() to Read a BMP File
there is this api:

The GetDIBColorTable function retrieves RGB (red, green, blue) color values from a range of entries in the color table of the DIB section bitmap that is currently selected into a specified device context.

UINT GetDIBColorTable(

    HDC hdc,      // handle of device context whose DIB is of interest
    UINT uStartIndex,      // color table index of first entry to retrieve
    UINT cEntries,      // number of color table entries to retrieve
    RGBQUAD *pColors      // pointer to buffer that receives color table entries

dereklAuthor Commented:
Alright, I can get a BITMAPINFOHEADER structure by calling GetObject to get a DIBSECTION object.  I guess what I need to know now is how to get to the RGBQUAD structures that hold the actual color data.  I know that these follow the BITMAPINFOHEADER structure in a BITMAPINFO structure, so how do I get a BITMAPINFO structure?  Can I just cast the BITMAPINFOHEADER I got from GetObject?
Have you taken a look at the KB article? There is the code you need.
IF you're bitmap is gotten from a *.bmp file then you can get the BITMAPINFOHEADER by simply reading in the file.  
   First read in the BITMAPFILEHEADER struct and then the BITMAPINFOHEADER.  ALL *.bmp start off with these two structs, BUT, the rest of the file depends on data in those two structs.  Give it a shot - the above works perfect.  
   Once you verify the bitmap is really 8bpp, just read in 256 RGBQUAD data.
All Courses

From novice to tech pro — start learning today.