Skip navigation

之前我创建的CompatibleBitmap是使用memDC来创建的(memDC = CreateCompatibleDC)
仔细看了MSDN关于CreateCompatibleBitmap的remark章节才清楚。原来memDC默认识单色的。新的bitmap必须使用hSrcDC来创建,才能出现彩色图。

The following is copied from MSDN

Note: When a memory device context is created, it initially has a 1-by-1 monochrome bitmap selected into it. If this memory device

context is used in CreateCompatibleBitmap, the bitmap that is created is a monochrome bitmap. To create a color bitmap, use the hDC that was used to create the memory device context, as shown in the following code:

    HDC memDC = CreateCompatibleDC ( hDC );
    HBITMAP memBM = CreateCompatibleBitmap ( hDC, nWidth, nHeight );
    SelectObject ( memDC, memBM );

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>