在用双缓冲方式画图时,显示出的图形全黑。
我用了 HPEN pen=CreatePen(PS_SOLID, 4, color);
HPEN oldpen=NULL;
oldpen=(HPEN)::SelectObject(m_dcMemory.GetSafeHdc(), pen);
自定义画笔还是不能显示出颜色。
不用双缓冲没有这个问题。
我用了 HPEN pen=CreatePen(PS_SOLID, 4, color);
HPEN oldpen=NULL;
oldpen=(HPEN)::SelectObject(m_dcMemory.GetSafeHdc(), pen);
自定义画笔还是不能显示出颜色。
不用双缓冲没有这个问题。
看MSDN的说明:
Memory Device Contexts
The memory device context stores bitmapped images for a particular device. An application can create a memory device context by calling the CreateCompatibleDC function and supplying a handle that identifies a device context for a particular device. When the system processes this call, it creates a bitmap having a color format compatible with the original device. Because the bitmap is compatible with the given device, a memory device context is also sometimes referred to as a compatible device context. The original bitmap in a memory device context is simply a placeholder. Its dimensions are one pixel by one pixel. Before an application can begin drawing, it must select a bitmap with the appropriate width and height into the device context by calling the SelectObject function. Once the new bitmap is selected into the memory device context, an application can begin using the device context to store images. For more information about bitmaps and bitmap operations, see Bitmaps.
if(!m_dcMemory.CreateCompatibleDC(pDC)) //pDC为屏幕DC
{
::PostQuitMessage(0);
}
// 创建位图
m_Bmp.CreateCompatibleBitmap(&m_dcMemory, rt.Width(), rt.Height());
::SelectObject(m_dcMemory.GetSafeHdc(), m_Bmp);
只是这种方法创建的位图,在改变桌面分辨率后可能会出问题。 10000*10000的256色位图已经超过256兆了,偶的机器根本创建不了,直接返回空。