bitmap with the destination bitmap using the Boolean OR operator.
? NOTSRCCOPY 将反色后的源拷贝到目的区 Copies the inverted source bitmap to
the destination.
? PATINVERT 源和目的间进行XOR操作 Combines the destination bitmap with the
pattern using the Boolean XOR operator.
? SRCAND 源和目的间进行AND操作 Combines pixels of the destination and
source bitmaps using the Boolean AND operator.
? SRCCOPY 复制源到目的区 Copies the source bitmap to the destination
bitmap.
? SRCINVERT 源和目的间进行XOR操作 Combines pixels of the destination and
source bitmaps using the Boolean XOR operator.
? SRCPAINT 源和目的间进行OR操作 Combines pixels of the destination and
source bitmaps using the Boolean OR operator.
? WHITENESS 输出区域为白色 Turns all output white.
下面用代码演示这种方法:
CYourView::OnDraw(CDC* pDC)
{
CDC memDC;//定义一个兼容DC
memDC.CreateCompatibleDC(pDC);//创建DC
CBitmap bmpDraw;
bmpDraw.LoadBitmap(ID_BMP) ;//装入DDB
CBitmap* pbmpOld=memDC.SelectObject(&bmpDraw) ;
//保存原有DDB,并选入新DDB入DC
pDC->BitBlt(0,0,20,20,&memDC,0,0,SRCCOPY) ;
//将源DC中(0,0,20,20)复制到目的DC(0,0,20,20)
pDC->BitBlt(20,20,40,40,&memDC,0,0,SRCAND);
//将源DC中(0,0,20,20)和目的DC(20,20,40,40)中区域进行AND操作 memDC.SelectObject(pbmpOld) ;//选入原DDB
}
(图标并不是一个GDI对象,所以不需要选入DC)在MFC中没有一个专门的图标类,因为图标的操作比较简单,使用HICON CWinApp::LoadIcon( UINT nIDResource )或是HICON CWinApp::LoadStandardIcon( LPCTSTR lpszIconName ) 装入后就可以利用BOOL
CDC::DrawIcon( int x, int y, HICON hIcon )绘制。由于在图标中可以指定透明区域,所以在某些需要使用非规则图形而且面积不大的时候使用图标会比较简单。下面给出简单的代码:
OnDraw(CDC* pDC)
{
HICON hIcon1=AfxGetApp()->LoadIcon(IDI_I1);
本文来自电脑杂谈,转载请注明本文网址:
https://www.pc-fly.com/a/ruanjian/article-35251-12.html
赤裸裸千里万里挑衅和侵犯别国做出愚蠢行为是要付出代价的
赶紧买两袋南方黑芝麻糊压压惊