The result of CreateCompatibleDC only has two colors

后端 未结 1 1426
太阳男子
太阳男子 2020-12-07 02:34

In the following code, anytime CreateCompatibleDC is called, the resulting device context only has two colors: black and white.

case WM_PAINT:
        {
             


        
相关标签:
1条回答
  • 2020-12-07 02:51

    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.

    0 讨论(0)
提交回复
热议问题