BOOL BitBlt( HDC hdcDest, // handle to destination DC int nXDest, // x-coord of destination upper-left corner int nYDest, // y-coord of destination upper-left corner int nWidth, // width of destination rectangle int nHeight, // height of destination rectangle HDC hdcSrc, // handle to source DC int nXSrc, // x-coordinate of source upper-left corner int nYSrc, // y-coordinate of source upper-left corner DWORD dwRop // raster operation code );
CBitmap MemBitmap;//定义一个位图对象//随后建立与屏幕显示兼容的内存显示设备
MemDC.CreateCompatibleDC(NULL);
//这时还不能绘图,因为没有地方画 ^_^
//下面建立一个与屏幕显示兼容的位图,至于位图的大小嘛,可以用窗口的大小
MemBitmap.CreateCompatibleBitmap(pDC,nWidth,nHeight);
//将位图选入到内存显示设备中
//只有选入了位图的内存显示设备才有地方绘图,画到指定的位图上
CBitmap *pOldBit=MemDC.SelectObject(&MemBitmap);//先用背景色将位图清除干净,这里我用的是白色作为背景
//你也可以用自己应该用的颜色
MemDC.FillSolidRect(0,0,nWidth,nHeight,RGB(255,255,255));//绘图
MemDC.MoveTo(……);
MemDC.Polygon(……);//将内存中的图拷贝到屏幕上进行显示
pDC->BitBlt(0,0,nWidth,nHeight,&MemDC,0,0,SRCCOPY);//绘图完成后的清理
MemBitmap.DeleteObject();
MemDC.DeleteDC();
HDC hdcDest, // handle to destination DC
int nXDest, // x-coord of destination upper-left corner
int nYDest, // y-coord of destination upper-left corner
int nWidth, // width of destination rectangle
int nHeight, // height of destination rectangle
HDC hdcSrc, // handle to source DC
int nXSrc, // x-coordinate of source upper-left corner
int nYSrc, // y-coordinate of source upper-left corner
DWORD dwRop // raster operation code
);
这样我从内存设备拷贝出来就会全部覆盖原来的图像,我要的是只拷贝多边形内的图像到另一个图像的相应位置光栅操作我弄不太明白 是在不行就只能处理位图了
HDC hdcDest, // 目标设备场景DC
int nXDest, // x-对目标DC中目标矩形左上角位置进行描述的那个点。用目标DC的逻辑坐标表示
int nYDest, // y-对目标DC中目标矩形左上角位置进行描述的那个点。用目标DC的逻辑坐标表示
int nWidth, // 欲传输图象的宽度
int nHeight, // 欲传输图象的高度
HDC hdcSrc, // 源设备场景。如光栅运算未指定源,则应设为0
int nXSrc, // x-对源DC中源矩形左上角位置进行描述的那个点。用源DC的逻辑坐标表示
int nYSrc, // y-对源DC中源矩形左上角位置进行描述的那个点。用源DC的逻辑坐标表示
DWORD dwRop // 传输过程要执行的光栅运算
);
/* Ternary raster operations */
#define SRCCOPY (DWORD)0x00CC0020 /* dest = source */
#define SRCPAINT (DWORD)0x00EE0086 /* dest = source OR dest */
#define SRCAND (DWORD)0x008800C6 /* dest = source AND dest */
#define SRCINVERT (DWORD)0x00660046 /* dest = source XOR dest */
#define SRCERASE (DWORD)0x00440328 /* dest = source AND (NOT dest ) */
#define NOTSRCCOPY (DWORD)0x00330008 /* dest = (NOT source) */
#define NOTSRCERASE (DWORD)0x001100A6 /* dest = (NOT src) AND (NOT dest) */
#define MERGECOPY (DWORD)0x00C000CA /* dest = (source AND pattern) */
#define MERGEPAINT (DWORD)0x00BB0226 /* dest = (NOT source) OR dest */
#define PATCOPY (DWORD)0x00F00021 /* dest = pattern */
#define PATPAINT (DWORD)0x00FB0A09 /* dest = DPSnoo */
#define PATINVERT (DWORD)0x005A0049 /* dest = pattern XOR dest */
#define DSTINVERT (DWORD)0x00550009 /* dest = (NOT dest) */
#define BLACKNESS (DWORD)0x00000042 /* dest = BLACK */
#define WHITENESS (DWORD)0x00FF0062 /* dest = WHITE */