如何从CPaintDC图像(屏幕)到Cimage?
CPaintDC dc(this);
dc.FillSolidRect( 20-1, 200+1, 200*3, 400+2, (COLORREF) 0x0 );
dc.SelectObject(pen1);
dc.MoveTo(20,400);
for(int i = 0;i<200;i++)
{
dc.LineTo(20 + x[i], 600 - y1[i]);
dc.FillSolidRect( 20 + x[i]-1,600- y1[i]-1, 3, 3, (COLORREF) 0xff00 );
}
(使用以下命令,输出一条警告消息,说它触发了一个关于"dbgrptt.c - Debug CRT Reporting Functions"的断点???所以我一定是失踪了还是做错了什么?
CImage myimage;
myimage.GetDC();
myimage.Save("C:\Projects_example\sweep.jpg");
myimage.ReleaseDC();
CRect rc;
GetClientRect(rc);
CImage myimage;
myimage.Create(rc.Width(), rc.Height(), 24);
CDC memdc;
memdc.CreateCompatibleDC(&dc);
CBitmap * pOldBitmap = memdc.SelectObject(CBitmap::FromHandle((HBITMAP)myimage));
memdc.BitBlt(0, 0, rc.Width(), rc.Height(), &dc, 0, 0, SRCCOPY);
memdc.SelectObject(pOldBitmap);
此时,您的myimage
对象应该有dc
上绘制的内容的副本。