How to get BITMAPINFOHEADER

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.
dereklAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

edeyCommented:
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
   );


GL
Mike
0
chensuCommented:
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
http://support.microsoft.com/support/kb/articles/q158/8/98.asp
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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?
0
chensuCommented:
Have you taken a look at the KB article? There is the code you need.
0
GlennDeanCommented:
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.
   Glenn
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Development

From novice to tech pro — start learning today.