Reputation: 533
Why would passing a compatible DC and the DC the compatible one is based on to CreateCompatibleBitmap()
give different results?
This one creates a monochrome bitmap:
CDC dcMem;
dcMem.CreateCompatibleDC(mydc);
destBitmap->CreateCompatibleBitmap(&dcMem, rect.Width(), rect.Height());
CBitmap* pBmpOld = dcMem.SelectObject (destBitmap);
// ... Draw on to the DC ....
dcMem.SelectObject (pBmpOld);
This one creates the correct color bitmap:
CDC dcMem;
dcMem.CreateCompatibleDC(mydc);
destBitmap->CreateCompatibleBitmap (mydc, rect.Width(), rect.Height());
CBitmap* pBmpOld = dcMem.SelectObject (destBitmap);
// ... Draw on to the DC ....
dcMem.SelectObject (pBmpOld);
TIA!!
Upvotes: 2
Views: 108
Reputation: 19097
As per the comments, have a look at the CreateCompatibleBitmap
documentation:
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 ...
Upvotes: 2