开发者

CreateDIBitmap creates Black&White image

开发者 https://www.devze.com 2023-03-20 01:27 出处:网络
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).

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号