Reputation: 2730
I am working on an application that does some GDI+ drawing to an HBITMAP selected in an HDC. After drawing is complete, I need to:
I am really lost, and I am really new to GDI+ and handles. Can anyone help me out?
Upvotes: 0
Views: 594
Reputation: 3401
First off, you draw into the HDC, not the HBITMAP. The HBITMAP gets the data drawn through the HDC. You need to create a new bitmap to get the 4bpp data. However such a color depth is too low (16 colors only). Is it palette based? The conversion (reduction of the color depth) may not be really good, or may not work the way you would like. I would suggest reading the RGB values from the 32-bit bitmap, and then convert them to 4bpp using your own code. Otherwise you will rather need an image library instead, which will perform the conversion as needed.
Upvotes: 1
Reputation: 2201
GetDIBits is the function you'd use for both converting and retrieving raw bits, that is (2) and (3).
If you don't yet have a handle to BITMAP, you'll have to create a new DC with CreateCompatibleDC, create a compatible bitmap on it and do a BitBlt from source DC to target DC. Then perform GetDIBits on target DC and bitmap to retrieve the data you need.
Upvotes: 4