2024年2月21日发(作者:)
类
CDC *pDC=GetDC();pDC->MoveTo(m_pOrigin);pDC->LineTo(m_pPoint);ReleaseDC(pDC);CPen画笔绘制彩色线条
0000
00
00
000CPen(int nPenStyle,int nWidth,COLORREF crColor);
COLORREF RGB(BYTE bRed,BYTE bGreen,BYTE bBule);
CPen pen(PS_SOLID,1,RGB(255,0,0));0000
CClientDC dc(this);
CPen *pOldPen=Object(&pen);(m_ptOrigin);(point);
000
00 Object(pOldPen);CBrush画刷画图0000
BOOL BitBlt( int x, int y, int nWidth, int nHeight, CDC* pSrcDC, int xSrc, int ySrc,
DWORD dwRop ); 0
BOOL StretchBlt( int x, int y, int nWidth, int nHeight, CDC* pSrcDC, int xSrc,
int ySrc, int nSrcWidth, int nSrcHeight, DWORD dwRop );00
tDC类
00
wsDC类00CRect rect;GetClientRect(&rect);//
0
000// Center led within an oversized window000
//
if(() >= LED_SIZE && () >= LED_SIZE)
{
}000
00int nWidth = ();int nHeight = ();
+= (nWidth - LED_SIZE)/2; -= (nWidth - LED_SIZE)/2; += (nHeight - LED_SIZE)/2;
-= (nHeight - LED_SIZE)/2;00//0// Prepare temporary DCs and bitmaps//
00
CBitmap TransBitmap;0
Bitmap(LED_SIZE,LED_SIZE,1,1,NULL);
CBitmap bitmapTemp;CBitmap* pBitmap = &m_LedBitmap;CDC srcDC;00
0
CDC dcMask;00CDC TempDC;
CompatibleDC(pDC);CompatibleDC(pDC);0
CompatibleDC(pDC);000CBitmap* pOldBitmap = Object(pBitmap);CBitmap* pOldMaskbitmap = Object(&TransBitmap);
CompatibleBitmap(pDC,LED_SIZE,LED_SIZE);
//
000// Work with tempDC and bitmapTemp to reduce flickering
0
0//
CBitmap *pOldBitmapTemp = Object(&bitmapTemp);
(0, 0, LED_SIZE, LED_SIZE, pDC, , ,
00SRCCOPY);
//// Create mask//0
0000COLORREF OldBkColor = olor(RGB(255,0,255));
(0, 0, LED_SIZE, LED_SIZE,&srcDC, nMode*LED_SIZE,
nLEDColor+nShape, SRCCOPY);
0
olor(OldBkColor);//
0
00// Using the IDB_LEDS bitmap, index into the bitmap for the appropriate
// LED. By using the mask color (RGB(255,0,255)) a mask has been
00created
00// so the bitmap will appear transparent.
//
(0, 0, LED_SIZE, LED_SIZE, &srcDC, nMode*LED_SIZE,
0
nLEDColor+nShape, SRCINVERT);
000
(0, 0, LED_SIZE, LED_SIZE,&dcMask, 0, 0, SRCAND);
(0, 0, LED_SIZE, LED_SIZE, &srcDC, nMode*LED_SIZE,
nLEDColor+nShape, SRCINVERT);
0
//0
00// Since the actual minipulation is done to tempDC so there is minimal
// flicker, it is now time to draw the result to the screen.00
//
pDC->BitBlt(, , LED_SIZE, LED_SIZE, &TempDC, 0, 0,
00SRCCOPY);
//// House cleaning0
00//
Object(pOldBitmap);Object(pOldMaskbitmap);Object(pOldBitmapTemp);VERIFY(DC());VERIFY(DC());VERIFY(DC());VERIFY(Object());000
00000000
发布评论