Bitblt and CBitmap问题,快来指点。
shu 2002-04-02 02:01:44 谁能解释一下,这是什么道理:
pDC是当前设备上下文指针,mybitmap是此前已准备好的位图。
CDC dcImage, dcTrans;
// Create two memory dcs for the image and the mask
dcImage.CreateCompatibleDC(pDC);
dcTrans.CreateCompatibleDC(pDC);
dcImage.SelectObject(&mybitmap);
dcImage.SetBkColor(crColour);//crColour 是指定的一个颜色与我的位图某种颜色相同
CBitmap bitmapTrans;
bitmapTrans.CreateBitmap(nWidth, nHeight, 1, 1, NULL);//创建黑白两色位图,此时是全黑的
dcTrans.SelectObject(&bitmapTrans);
dcTrans.BitBlt(0, 0, nWidth, nHeight, &dcImage, 0, 0, SRCCOPY);
pDC->BitBlt(x, y, nWidth, nHeight, &dcTrans, 0, 0, SRCCOPY);
上面程序执行结果显示我的位图的掩模,既与指定的crColour相同的颜色为白,其它为黑。
我不明白的是:为什么一幅彩色位图画到黑白位图上,与其相关DC的背景色一样的颜色变成白的其他是黑的?