为什么要将兼容的 DC 以及兼容 DC 所基于的 DC 传递给 CreateCompatibleBitmap()
给出不同的结果?
这创建了一个单色位图:
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);
这创建了正确的颜色位图:
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!!
最佳答案
根据评论,看看 CreateCompatibleBitmap
文档:
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 ...
关于winapi - MFC:CBitmapCreateCompatibleBitmap() 根据传递给它的两个兼容的 CDC 给出不同的结果?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61764469/