CreateDIBitmap creates Black&White image
For someone who knows CreateDIBitmap troubleshootings
When I create it, passing all the parameters hopefully correct, I create it with passing data array (bits array). This array is taken from the same bitmap (idea is to create a new copy; for 开发者_高级运维testing purpose). But after creation (it returns correct handle), the bitmap is correct, but palette is B&W. No colors. Why? Who knows?
Your first comment is the key to the issue. You're using a memory device context, obtained through CreateCompatibleDC(), and the default bitmap selected in memory DCs is monochrome (1 bit per pixel).
CreateDIBitmap() uses that device context to determine the bit depth of the DIB it creates, so you end up with a monochrome DIB.
You could use CreateDIBSection() to supply your own bit depth, but the simplest solution is probably to pass hdcScreen
to CreateDIBitmap()
instead of compatibleDC
.
精彩评论