The result of CreateCompatibleDC only has two colors

那年仲夏 提交于 2019-12-01 18:23:41

Change this:

HBITMAP membm=CreateCompatibleBitmap(memdc,width,height);

To this:

HBITMAP membm=CreateCompatibleBitmap(hdc,width,height);

When you create a compatible DC, it's created with a bitmap--but that bitmap is always a 1x1 monochrome bitmap (i.e., a single pixel that's either black or white), regardless of what sort of DC it's compatible with.

As a result, if you create a bitmap compatible with that DC, you'll get a larger monochrome bitmap.

If, however, you create a bitmap compatible with the original DC, then you'll get a bitmap of the requested size and the color depth of the original DC.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!