void Bullet::Paint(HDC& hmdc) { switch (getDirection()) { case FRONT: SelectObject(g_hbufdc,g_hBullet[0]); TransparentBlt(hmdc,m_pLocation.getX()-40,m_pLocation.getY()-25,80,50,g_hbufdc,0,0,80,50,RGB(0,0,0)); break; case RETREAT: SelectObject(g_hbufdc,g_hBullet[1]); TransparentBlt(hmdc,m_pLocation.getX()-40,m_pLocation.getY()-25,80,50,g_hbufdc,0,0,80,50,RGB(0,0,0)); break; case LEFT: SelectObject(g_hbufdc,g_hBullet[2]); TransparentBlt(hmdc,m_pLocation.getX()-25,m_pLocation.getY()-40,50,80,g_hbufdc,0,0,50,80,RGB(0,0,0)); break; case RIGHT: SelectObject(g_hbufdc,g_hBullet[3]); TransparentBlt(hmdc,m_pLocation.getX()-25,m_pLocation.getY()-40,50,80,g_hbufdc,0,0,50,80,RGB(0,0,0)); break; default: break; } if (bulletExplode<8) { fireX=m_tOwner->Location().getX(); fireY=m_tOwner->Location().getY(); switch (getDirection()) { case RETREAT: fireY+=excursion; break; case LEFT: fireX-=(20+excursion); fireY-=7; break; case RIGHT: fireX+=(20+excursion); fireY-=7; break; case FRONT: fireY-=(15+excursion); break; default: break; } SelectObject(g_hbufdc,g_hBulletEx[bulletExplode++]); TransparentBlt(hmdc,fireX-20,fireY-20,40,40,g_hbufdc,0,0,40,40,RGB(0,0,0)); } Move(); /*BitBlt(hmdc,m_pLocation.getX()-7,m_pLocation.getY()-7,15,15,g_hbufdc,0,0,SRCCOPY);*/ }
//-----------------------------------【Game_Paint( )函数】-------------------------------------- // 描述:绘制函数,在此函数中进行绘制操作 //-------------------------------------------------------------------------------------------------- VOID Game_Paint( HWND hwnd ) { //先贴上背景图 SelectObject(g_mdc,g_hBackGround); BitBlt(g_hdc,0,0,WINDOW_WIDTH,WINDOW_HEIGHT,g_mdc,0,0,SRCCOPY); //采用BitBlt函数在g_hdc中先贴上背景图 //贴第一张人物图 SelectObject(g_mdc,g_hCharacter1); TransparentBlt(g_hdc,0,WINDOW_HEIGHT-650,535,650,g_mdc,0,0,535,650,RGB(0,0,0));//透明色为RGB(0,0,0) //贴第二张人物图 SelectObject(g_mdc,g_hCharacter2); TransparentBlt(g_hdc,500,WINDOW_HEIGHT-650,506,650,g_mdc,0,0,506,650,RGB(0,0,0));//透明色为RGB(0,0,0) }
//非战斗 VOID Game_Paint(HWND hwnd){ //背景 SelectObject(g_bufdc, g_hBackGround_mv); BitBlt(g_mdc, 0, 0, WINDOW_WIDTH, WINDOW_HEIGHT, g_bufdc, g_iX - WINDOW_WIDTH / 2, g_iY - WINDOW_HEIGHT / 2, SRCCOPY); //角色(移动和站立) if (g_tNow - g_mv < 100){ SelectObject(g_bufdc, g_hSprite[0]); } else{ SelectObject(g_bufdc, g_hSprite[1]); } TransparentBlt(g_mdc, WINDOW_WIDTH / 2 - 46, WINDOW_HEIGHT / 2 - 99, 85, 113, g_bufdc, g_iNum_mv * 85, g_iDirection*113.5, 85, 113, RGB(255, 255, 255)); //覆盖层 SelectObject(g_bufdc, g_hBackGround_mvzd); TransparentBlt(g_mdc, 0, 0, WINDOW_WIDTH, WINDOW_HEIGHT, g_bufdc, g_iX - WINDOW_WIDTH / 2, g_iY - WINDOW_HEIGHT / 2, WINDOW_WIDTH, WINDOW_HEIGHT, RGB(255, 255, 255)); //下边框 SelectObject(g_bufdc, g_hxbk2); TransparentBlt(g_mdc, 0, WINDOW_HEIGHT - 88 - 76, 819, 110, g_bufdc, 7, 550, 812, 110, RGB(255, 255, 255)); if (hdtflag == 1){ for (int i = 0; i < WINDOW_WIDTH / 5; i++){ for (int j = 0; j < 5; j++) BitBlt(g_hdc, i + j*WINDOW_WIDTH / 5, 0, 1, WINDOW_HEIGHT, g_mdc, i + j*WINDOW_WIDTH / 5, 0, SRCCOPY); Sleep(20); } hdtflag = 0; } else{ BitBlt(g_hdc, 0, 0, WINDOW_WIDTH, WINDOW_HEIGHT, g_mdc, 0, 0, SRCCOPY); } //BitBlt(g_hdc, 0, 0, WINDOW_WIDTH, WINDOW_HEIGHT, g_mdc, 0, 0, SRCCOPY); g_tPre = GetTickCount(); //记录此次绘图时间 g_iNum_mv++; if (g_iNum_mv == 4) g_iNum_mv = 0; if (rand() % 100 == 1) { ReStart(); } }
VOID Game_Paint(HWND hwnd) { ball.x = 200 * cosf(ball.angle) + 320 ; ball.y = 200 * sinf(ball.angle) ; if (t <= 60) { ball.angle = easeIn(t, 60, PI / 2, 0); } else if (t <= 120) { ball.angle = easeOut(t - 60, 60, PI / 2 , PI / 2); }else if(t <= 180){ ball.angle = easeIn(t - 120, 60, -PI / 2, PI); } else if (t <= 240) { ball.angle = easeOut(t - 180, 60, -PI / 2, PI / 2); }else{ t = 0; } t++; //3.选用位图对象 SelectObject(g_bdc, g_hBackground); //4.贴图 BitBlt(g_mdc, 0, 0, WINDOW_WIDTH, WINDOW_HEIGHT, g_bdc, 0, 0, SRCCOPY); //SelectObject(g_bdc, g_hBall); //4.贴图 //BitBlt(g_mdc, 400, ball.y, 64, 64, g_bdc, 0, 0, SRCCOPY); SelectObject(g_bdc, g_hBall); TransparentBlt(g_mdc, ball.x, ball.y, 64, 64, g_bdc, 0, 0, 64, 64, RGB(0, 0, 0)); BitBlt(g_hdc, 0, 0, WINDOW_WIDTH, WINDOW_HEIGHT, g_mdc, 0, 0, SRCCOPY); }
LRESULT CALLBACK MainDialog::PictureBox_OnMessage(HWND hWnd, UINT Message, WPARAM wParam, LPARAM lParam) { switch(Message) { case STM_SETIMAGE: ::InvalidateRect(hWnd, NULL, FALSE); break; case WM_PAINT: { PAINTSTRUCT ps = {NULL}; HDC hdc = ::BeginPaint(hWnd, &ps); HBITMAP hBitmap = (HBITMAP)::SendMessage(hWnd, (UINT)STM_GETIMAGE, (WPARAM)IMAGE_BITMAP, (LPARAM)0L); if(!hBitmap) break; RECT rcClient = {NULL}; ::GetClientRect(hWnd, &rcClient); int iWidth = (rcClient.right - rcClient.left); int iHeight = (rcClient.bottom - rcClient.top); TransparentBlt(hdc, 0, 0, iWidth, iHeight, hBitmap, 0, 0, RGB(255, 0, 255), NULL); ::EndPaint(hWnd, &ps); } break; } return ::CallWindowProc(m_hDefaultPictureProc, hWnd, Message, wParam, lParam); };
void Car::draw(HDC drawcanvas) { int nx = boundingBox.x; int ny = boundingBox.y; HDC carDC = CreateCompatibleDC(drawcanvas); //HDC stretched = CreateCompatibleDC(drawcanvas); SelectObject(carDC, bitMap.image); SetStretchBltMode(carDC, COLORONCOLOR); //StretchBlt(stretched, nx, ny, boundingBox.w, boundingBox.h, carDC, 0,0,bitMap.width,bitMap.height, SRCCOPY); bool d = TransparentBlt( drawcanvas, nx, ny, boundingBox.w, boundingBox.h, carDC, 0, 0, boundingBox.w, boundingBox.h, RGB(128, 128, 128)); //Rectangle(drawcanvas, position.x, position.y, position.x+10, position.y+10); DeleteObject(carDC); //DeleteObject(stretched); }
BOOL CSonicImage::InternalDraw(HDC hdc, int x, int y, DRAW_PARAM * pDp) { CRect rtSrc, rtDest; rtDest = CalculateRectByDrawParam(x, y, pDp, rtSrc); if(IsAlphaChannelValid() || (pDp && (pDp->dwMask & DP_ALPHA))) { BLENDFUNCTION blend; blend.AlphaFormat = AC_SRC_ALPHA; blend.BlendFlags = 0; blend.BlendOp = AC_SRC_OVER; blend.SourceConstantAlpha = (pDp && (pDp->dwMask & DP_ALPHA)) ? pDp->cAlpha : 255; AlphaBlend(hdc, rtDest.left, rtDest.top, rtDest.Width(), rtDest.Height(), m_Dib.GetSafeHdc(), rtSrc.left, rtSrc.top, rtSrc.Width(), rtSrc.Height(), blend); } else { if(pDp && (pDp->dwMask & DP_COLOR_KEY)) { TransparentBlt(hdc, rtDest.left, rtDest.top, rtDest.Width(), rtDest.Height(), m_Dib.GetSafeHdc(), rtSrc.left, rtSrc.top, rtSrc.Width(), rtSrc.Height(), pDp->dwColorKey); } else if(pDp && (pDp->dwMask & DP_DEST_LIMIT || pDp->dwMask & DP_SCALE)) { StretchBlt(hdc, rtDest.left, rtDest.top, rtDest.Width(), rtDest.Height(), m_Dib.GetSafeHdc(), rtSrc.left, rtSrc.top, rtSrc.Width(), rtSrc.Height(), SRCCOPY); } else { BitBlt(hdc, rtDest.left, rtDest.top, rtDest.Width(), rtDest.Height(), m_Dib.GetSafeHdc(), rtSrc.left, rtSrc.top, SRCCOPY); } } return TRUE; }
VOID Snow_Paint() { if (g_SnowNum< PARTICLE_NUMBER) { SnowFlowers[g_SnowNum].x = rand() % g_rect.right; SnowFlowers[g_SnowNum].y = 0; SnowFlowers[g_SnowNum].exist = true; g_SnowNum++; } for (int i = 0; i<PARTICLE_NUMBER; i++) { if (SnowFlowers[i].exist) { SelectObject(g_bufdc, g_hSnow); TransparentBlt(g_mdc, SnowFlowers[i].x, SnowFlowers[i].y, 20, 20, g_bufdc, 0, 0, 20, 20, RGB(0, 0, 0)); if (rand() % 2 == 0) SnowFlowers[i].x += rand() % 6; else SnowFlowers[i].x -= rand() % 6; SnowFlowers[i].y += 10; if (SnowFlowers[i].y > g_rect.bottom) { SnowFlowers[i].x = rand() % g_rect.right; SnowFlowers[i].y = 0; } } } }
void CShader::AddTextToTextSurface(int x,int y,char *textContent,unsigned long textColor) { int w=m_textSurface.w; int h=m_textSurface.h; //添加文字内容 m_hDc_temp=CreateCompatibleDC(m_hDc); m_hDc_sf=CreateCompatibleDC(m_hDc); m_hBitmap=CreateCompatibleBitmap(m_hDc,w,h); HBITMAP hOldBitmap=(HBITMAP)SelectObject(m_hDc_temp,m_hBitmap); SetBkColor(m_hDc_temp,RGB(0,0,0)); SetTextColor(m_hDc_temp,textColor); TextOut(m_hDc_temp,x,y,textContent,strlen(textContent)); //添加图片信息 m_textSurface.ddSurface->GetDC(&m_hDc_sf); TransparentBlt(m_hDc_sf,0,0,w,h,m_hDc_temp,0,0,w,h,RGB(0,0,0)); m_textSurface.ddSurface->ReleaseDC(m_hDc_sf); //清理内存 SelectObject(m_hDc_temp,hOldBitmap); DeleteDC(m_hDc_temp); DeleteDC(m_hDc_sf); DeleteObject(m_hBitmap); DeleteObject(hOldBitmap); }
bool CDDB::PutBitmap( int x, int y, CDC *pDC, int xSrc, int ySrc, int dxSrc, int dySrc, int width, int height, DWORD dwRop, int alpha) { // Coordinate mode is not relative if ( m_CoordinateMode != CM_RELATIVE) GetRelativeCoordinate( &xSrc, &ySrc, &dxSrc, &dySrc); // Copy alphablended memory DC if ( alpha < 255) { BLENDFUNCTION blendFunc = { AC_SRC_OVER, 0, alpha, 0 }; // Copy memory bitmap AlphaBlend( m_DC, x, y, width, height, pDC->m_hDC, xSrc, ySrc, dxSrc, dySrc, blendFunc); } // Copy transparent memory DC else if ( dwRop == TRANSPARENT) { // Copy memory bitmap TransparentBlt( m_DC, x, y, width, height, pDC->m_hDC, xSrc, ySrc, dxSrc, dySrc, m_nTransColor); } // Copy memory DC else { // Copy memory bitmap m_DC.StretchBlt( x, y, width, height, pDC, xSrc, ySrc, dxSrc, dySrc, dwRop); } return true; }
//绘画头像 void CExpression::DrawItem(CDC * pDC, int iXPos, int iYPos, bool bSelectec) { CExpressionItem * pExpressionItem=GetExpressItem(iYPos*m_wMaxRow+iXPos); int nFaceIndex = iYPos*m_wMaxRow+iXPos; if (pExpressionItem!=NULL) { if (bSelectec) { pDC->FillSolidRect(iXPos*(EP_PIC_WHIDE+PIC_SPACE)+PIC_SPACE/2,iYPos*(EP_PIC_HIGHT+PIC_SPACE)+PIC_SPACE/2, EP_PIC_WHIDE+PIC_SPACE,EP_PIC_HIGHT+PIC_SPACE,RGB(255,255,255)); pDC->Draw3dRect(iXPos*(EP_PIC_WHIDE+PIC_SPACE)+PIC_SPACE/2,iYPos*(EP_PIC_HIGHT+PIC_SPACE)+PIC_SPACE/2, EP_PIC_WHIDE+PIC_SPACE,EP_PIC_HIGHT+PIC_SPACE,RGB(28,57,208),RGB(28,57,208)); } else { pDC->FillSolidRect(iXPos*(EP_PIC_WHIDE+PIC_SPACE)+PIC_SPACE/2,iYPos*(EP_PIC_HIGHT+PIC_SPACE)+PIC_SPACE/2, EP_PIC_WHIDE+PIC_SPACE,EP_PIC_HIGHT+PIC_SPACE,RGB(255,255,255)); } //装载图片 TCHAR szFileName[MAX_PATH]=TEXT(""); _snprintf(szFileName,sizeof(szFileName),TEXT("%s\\Face\\%d.gif"),m_szPath, nFaceIndex); CImage ImageFace; if ( SUCCEEDED(ImageFace.Load(szFileName) ) ) { //背景判断 COLORREF rfColor = ImageFace.GetPixel(0,0); TransparentBlt(pDC->GetSafeHdc(), iXPos*(EP_PIC_WHIDE+PIC_SPACE)+PIC_SPACE,iYPos*(EP_PIC_HIGHT+PIC_SPACE)+PIC_SPACE, EP_PIC_WHIDE, EP_PIC_HIGHT, ImageFace.GetDC(), 0, 0, EP_PIC_WHIDE, EP_PIC_HIGHT, rfColor); ImageFace.ReleaseDC(); } } return; }
BOOL CSkinBase::StretchBlt(CDC* pDCDest, int nXOriginDest, int nYOriginDest, int nWidthDest, int nHeightDest, CDC* pDCSrc, int nXOriginSrc, int nYOriginSrc, int nWidthSrc, int nHeightSrc, UINT uROP, COLORREF crTransparent) { // check to see if this is really just a BitBlt if (nWidthDest == nWidthSrc && nHeightDest == nHeightSrc) { return BitBlt(pDCDest, nXOriginDest, nYOriginDest, nWidthDest, nHeightDest, pDCSrc, nXOriginSrc, nYOriginSrc, uROP, crTransparent); } // else pick whether its transparent or not if (crTransparent != (COLORREF)-1) { return TransparentBlt(pDCDest, nXOriginDest, nYOriginDest, nWidthDest, nHeightDest, pDCSrc, nXOriginSrc, nYOriginSrc, nWidthSrc, nHeightSrc, crTransparent); } else { return pDCDest->StretchBlt(nXOriginDest, nYOriginDest, nWidthDest, nHeightDest, pDCSrc, nXOriginSrc, nYOriginSrc, nWidthSrc, nHeightSrc, uROP); } return TRUE; }
void Painter::Draw(const Animation& ani,int x,int y,int w,int h) { if(ani.Stoped())return; const Tile& tile=ani.GetTile(); //过滤透明色的位块传输 TransparentBlt(hcompdc,x,y,w,h,tile.pPic->hdc,tile.picx,tile.picy,tile.tilew,tile.tileh,RGB(0,0,0)); }
void GameUpdate(HWND hwnd, DWORD tickMilliSecond) { SelectObject(gBufDC, gBmpBackground); BitBlt(gMemDC, 0, 0, 800, 600, gBufDC, 0, 0, SRCCOPY); if (snow[gSnowNum].isActive == false) { snow[gSnowNum].isActive = true; snow[gSnowNum].x = rand()%gRect.right; snow[gSnowNum].y = 0; gSnowNum++; } for (int i = 0; i < gSnowNum; i++) { snow[i].x += (rand() % 13) - 6; snow[i].y += (rand() % 3) + 5; if (snow[i].x >= gRect.right) { snow[i].x = gRect.right - 10; } else if (snow[i].x <= gRect.left) { snow[i].x = gRect.left + 10; } if (snow[i].y >= gRect.bottom) { snow[i].y = 0; snow[i].x = rand() % gRect.right; } SelectObject(gBufDC, gBmpSprite); TransparentBlt(gMemDC, snow[i].x, snow[i].y, 30, 30, gBufDC, 0, 0, 30, 30, RGB(0, 0, 0)); } BitBlt(gHDC, 0, 0, 800, 600, gMemDC, 0, 0, SRCCOPY); }
//动图绘制 void AnimaSprite::DrawRowCol(HDC hdc,int x,int y,int nRow,int nCol,BOOL bTrans,COLORREF crTrans) { HDC hdcMem = CreateCompatibleDC(hdc); HBITMAP hbmOld = (HBITMAP)SelectObject(hdcMem,m_hbm); TransparentBlt(hdc,x,y,m_nFrameWidth,m_nFrameHeight,hdcMem,m_nFrameWidth*nCol,m_nFrameHeight*nRow,m_nFrameWidth,m_nFrameHeight,crTrans); SelectObject(hdcMem,hbmOld); DeleteObject(hbmOld); DeleteDC(hdcMem); }
/* Draws a single Bitmap into hDC, includes scaling. hDC: Drawing DC, fX: x-Pos, fY: y-Pos, fWidth: x-Dimensions, fWidth: y-Dimensions, hbm: Handle of Bitmap, bm: Loaded Bitmap, fInBitmap... = part of Bitmap rectangle. clrAlphaChannel: Which color should be transparent; */ void Painter::drawBitmapEx(float fX, float fY, float fWidth, float fHeight, float fInbitmapX, float fInBitmapY, float fInBitmapWidth, float fInBitmapHeight, HBITMAP hbm, BITMAP bm, COLORREF clrAlphaChannel){ HDC hdcMem = CreateCompatibleDC(hDCDraw); HBITMAP hbmOld = (HBITMAP)SelectObject(hdcMem, hbm); GetObject(hbm, sizeof(bm), &bm); TransparentBlt(hDCDraw, (int)fX, (int)fY, (int)fWidth, (int)fHeight, hdcMem, fInbitmapX, fInBitmapY, fInBitmapWidth, fInBitmapHeight, clrAlphaChannel); //BitBlt(hDC, _x, _y, bm.bmWidth, bm.bmHeight, hdcMem, 0, 0, SRCCOPY); SelectObject(hdcMem, hbmOld); DeleteDC(hdcMem); }
//位图绘制 void Sprite::DrawItem(HDC hdc) { HDC hdcMem = CreateCompatibleDC(hdc); HBITMAP hbmOld = (HBITMAP)SelectObject(hdcMem,m_hbm); TransparentBlt(hdc,m_Vx,m_Vy,m_Vwidth,m_Vheight,hdcMem,0,0,140,160,m_transcolor); SelectObject(hdcMem,hbmOld); DeleteObject(hbmOld); DeleteDC(hdcMem); }
void CButtonStyle::PaintBG(CDC *pDC,int iState) { CRect cltRect; GetClientRect(&cltRect); switch(iState){ case 1: TransparentBlt(pDC->m_hDC,0,0,cltRect.Width(), cltRect.Height(),m_hHdc,iX,iY1,iWidth,iHeight,RGB(255,0,255)); break; case 2: TransparentBlt(pDC->m_hDC,0,0,cltRect.Width(), cltRect.Height(),m_hHdc,iX,iY2,iWidth,iHeight,RGB(255,0,255)); break; case 3: TransparentBlt(pDC->m_hDC,0,0,cltRect.Width(), cltRect.Height(),m_hHdc,iX,iY3,iWidth,iHeight,RGB(255,0,255)); break; } }
void CDrawWnd::draw_bang(int x1, int y1, int x2, int y2) { HDC bgDC1 = CreateCompatibleDC(m_hdc); BITMAP temBmp1; HBITMAP hStartBmp1 = (HBITMAP) LoadImage(m_hinst,TEXT("res\\map\\爆炸.bmp"), IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE); ::GetObject(hStartBmp1, sizeof(temBmp1), &temBmp1); SelectObject(bgDC1, hStartBmp1); TransparentBlt(m_hdc, 40 + 40 * x1 , 40 + 40 * y1 , temBmp1.bmWidth, temBmp1.bmHeight, bgDC1, 0, 0, temBmp1.bmWidth, temBmp1.bmHeight, RGB(255, 255, 255)); DeleteDC(bgDC1); HDC bgDC = CreateCompatibleDC(m_hdc); BITMAP temBmp; HBITMAP hStartBmp = (HBITMAP) LoadImage(m_hinst, TEXT("res\\map\\爆炸.bmp"), IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE); ::GetObject(hStartBmp, sizeof(temBmp), &temBmp); SelectObject(bgDC, hStartBmp); TransparentBlt(m_hdc, 40 + 40 * x2 , 40 + 40 * y2 , temBmp.bmWidth, temBmp.bmHeight, bgDC, 0, 0, temBmp.bmWidth, temBmp.bmHeight, RGB(255, 255, 255)); DeleteDC(bgDC); }
void MenuImage::Draw() { BITMAP bitmap; BITMAP indicatorBitmap; //If menuitem needs to be centered if(!fixedPosition) { //Draw menu item GetObject(sprite, sizeof(BITMAP), &bitmap); HANDLE old = SelectObject(imageHDC, sprite); int xPos = (1280 / 2)-(bitmap.bmWidth / 2); TransparentBlt(drawDC, xPos, location.y, bitmap.bmWidth, bitmap.bmHeight, imageHDC, 0, 0, bitmap.bmWidth, bitmap.bmHeight, GetPixel(imageHDC, 1,1)); SelectObject(imageHDC, old); //BitBlt(drawDC, 0, 0, bitmap.bmWidth, bitmap.bmHeight, imageHDC, 0, 0, SRCCOPY); if(selected) { //Draw indicator GetObject(indicatorSprite, sizeof(indicatorBitmap), &indicatorBitmap); HANDLE old = SelectObject(imageHDC, indicatorSprite); TransparentBlt(drawDC, xPos-(indicatorBitmap.bmWidth) - 10, location.y, indicatorBitmap.bmWidth, indicatorBitmap.bmHeight, imageHDC, 0, 0, indicatorBitmap.bmWidth, indicatorBitmap.bmHeight, GetPixel(imageHDC, 1,1)); SelectObject(imageHDC, old); } }else { //If menuitem has fixed position if(selected) { //Draw indicator GetObject(indicatorSprite, sizeof(BITMAP), &bitmap); HANDLE old = SelectObject(imageHDC, indicatorSprite); TransparentBlt(drawDC, (location.x-bitmap.bmWidth)-10, location.y, bitmap.bmWidth, bitmap.bmHeight, imageHDC, 0, 0, bitmap.bmWidth, bitmap.bmHeight, GetPixel(imageHDC, 1,1)); SelectObject(imageHDC, old); } //Draw menu item GetObject(sprite, sizeof(BITMAP), &bitmap); HANDLE old = SelectObject(imageHDC, sprite); TransparentBlt(drawDC, location.x/* - (bitmap.bmWidth / 2)*/, location.y, bitmap.bmWidth, bitmap.bmHeight, imageHDC, 0, 0, bitmap.bmWidth, bitmap.bmHeight, GetPixel(imageHDC, 1,1)); SelectObject(imageHDC, old); } }
void CRyujo::Render(HDC hdc) { TransparentBlt(hdc, int(m_tInfo.fX - m_tInfo.fCX /2 ), int(m_tInfo.fY - m_tInfo.fCY /2 ), (int)m_tInfo.fCY, (int)m_tInfo.fCY, (*m_pMapBmp)[m_strEnemyID]->GetMemDC(), 0,0, (int)m_tInfo.fCX, (int)m_tInfo.fCY,RGB(255,0,216)); }
void GAME::Paint_Title(GAME::Others & a, HDC & buf, HDC & buf2) { if (a.pos.y > 180) { return; } a.pos.y += a.Speed; SelectObject(buf, a._bitMap[0]); TransparentBlt(buf2, a.pos.x, a.pos.y, a._size[0].cx, a._size[0].cy, buf, 0, 0, a._size[0].cx, a._size[0].cy, RGB(254, 254, 254)); }
void CBuffer::DisplayTransparentBitmap(HBITMAP hBitmap, int x, int y, RECT rPortion) { // Assign the width and height to shorten variables. int width = rPortion.right - rPortion.left, height = rPortion.bottom - rPortion.top; // Select the bitmap handle into the extra hdc that holds the bitmap SelectObject(hdcBitmap, hBitmap); TransparentBlt(hdcBack, x, y, width, height, hdcBitmap, rPortion.left, rPortion.top, width, height, TRANSPARENT_COLOR); }
void putImageTransparent(ACL_Image *pImage,int x,int y,int width,int height, ACL_Color bkColor) { HDC hbitmapdc; ACL_ASSERT_BEGIN_PAINT; hbitmapdc = CreateCompatibleDC(g_hmemdc); SelectObject(hbitmapdc, pImage->hbitmap); if(width == -1)width = pImage->width; if(height == -1)height = pImage->height; TransparentBlt(g_hmemdc,x,y,width,height,hbitmapdc,0,0,pImage->width,pImage->height,bkColor); DeleteDC(hbitmapdc); }
void CSprite::Draw(HDC buffer) { int cF = (int)curFrame; TransparentBlt(buffer, (int)curX, (int)curY, spriteFrames[cF].spriteRect.right, spriteFrames[cF].spriteRect.bottom, gfxSpriteMap.graphicDC, spriteFrames[cF].spriteRect.left, spriteFrames[cF].spriteRect.top, spriteFrames[cF].spriteRect.right, spriteFrames[cF].spriteRect.bottom, 0x00FF00); }
void CSnake::DrawSnack(HDC hDC,CPanel *pPanel) { //取得所有节点位置 int *x=new int[m_length+2]; int *y=new int[m_length+2]; GetSnack(x,y); //画画 HBITMAP oldbmp; //头 int hl=pPanel->GetGcx() * x[0]; int ht=pPanel->GetGcy() * y[0]; int hcx=pPanel->GetGcx(); int hcy=pPanel->GetGcy(); if(m_issk) { oldbmp=(HBITMAP)SelectObject(m_bmDC,m_shrunken); m_issk=false; } else { oldbmp=(HBITMAP)SelectObject(m_bmDC,m_headbmp); m_issk=true; } TransparentBlt(hDC,hl,ht,hcx,hcy,m_bmDC,0,0,47,47,RGB(255,0,0)); SelectObject(m_bmDC,m_nodebmp); //节点 for(int i=1;i<=m_length+1;i++) { int nl=pPanel->GetGcx() * x[i]; int nt=pPanel->GetGcy() * y[i]; int ncx=pPanel->GetGcx(); int ncy=pPanel->GetGcy(); TransparentBlt(hDC,nl,nt,ncx,ncy,m_bmDC,0,0,47,47,RGB(255,0,0)); } SelectObject(m_bmDC,oldbmp); delete []x; delete []y; }
//注: 更新操作全部在后台设备描述表完成 然后把后台的显示到前景 因为内存的速度远远大于显示器 void CLaoYangWnd::Update() { static int oldTime=0;//计时器 int newTime=GetTickCount();//返回当前时间 if(newTime-oldTime<100)//50毫秒走一步 return; oldTime=newTime;//更新时间 int i,j; ::FillRect(this->hbackdc,&this->clientRC,(HBRUSH)GetStockObject(WHITE_BRUSH));//白色刷子擦除客户区域 ///////////////画网格////////////////// for(i = 0;i<50*20;i+=20) { ::MoveToEx(this->hbackdc,i,0,NULL); ::LineTo(this->hbackdc,i,50*15); } for(i = 0;i<50*15;i+=15) { ::MoveToEx(this->hbackdc,0,i,NULL); ::LineTo(this->hbackdc,50*20,i); } ///////////////画地图/////////////////// HBRUSH hb = ::CreateSolidBrush(RGB(0,0,0)); ::SelectObject(this->hbackdc,hb); for(j = 0;j<51;j++) for(i = 0;i<51;i++) if('1' == path[j][i]) ::Rectangle(this->hbackdc,i*20,j*15,i*20+20,j*15+15); //////////////画路径//////////////////// char buffer[500] = {0}; sprintf(buffer,"起点(%d,%d) 终点(%d,%d)",res[this->sumway-1].y, res[this->sumway-1].x,res[0].y,res[0].x); TextOut(hbackdc,450,0,buffer,strlen(buffer)); HBRUSH hbway = ::CreateSolidBrush(RGB(0,255,0)); ::SelectObject(this->hbackdc,hbway); for(i = this->sumway-1 /*- this->step*/;i>=0;i--) { int x1 = res[i].y*20,y1 = res[i].x*15; int x2 = x1+20,y2 = y1+15; ::Rectangle(this->hbackdc,x1,y1,x2,y2); } //////////////贴位图/////////////////// TransparentBlt(this->hbackdc,res[this->sumway - this->step-1].y*20, res[this->sumway - this->step-1].x*15, w,h,this->memDC,0,0,this->w,this->h,GetPixel(this->memDC,0,0)); if(this->sumway - this->step > 1)//行走的实现 this->step++; //////////////后台设备描述表在前景中显示/////////////////////////// ::BitBlt(this->hdc,0,0,this->clientRC.right,this->clientRC.bottom,this->hbackdc,0,0,SRCCOPY); ::DeleteObject(hbway); ::DeleteObject(hb); }
/////ゲージ描画///////// int OIL::Paint_Gage(HDC hdc) { HDC hdc_work; hdc_work = CreateCompatibleDC(hdc); SelectObject(hdc_work, hb_OilGage); TransparentBlt(hdc, 10, 20, 254, 35, hdc_work, 0, 0, 254, 35, RGB(255, 255, 255)); DeleteDC(hdc_work); return 0; }
//----------------------------------------------------------- void DrawStone( HDC hdc, int x, int y, char stone) { HDC memDC = CreateCompatibleDC(hdc); HBITMAP old; if( stone == BLACK) old = (HBITMAP)SelectObject(memDC, hBlack); else old = (HBITMAP)SelectObject(memDC, hWhite); // BitBlt(hdc, x, y, 29, 29, memDC, 0, 0, SRCCOPY); TransparentBlt(hdc, x, y, 29, 29, memDC, 0, 0, 29, 29, RGB(255, 0, 0)); SelectObject(memDC, old); DeleteDC(memDC); }
//////オイルパワーの描画//////////// int OIL::Paint_Oil(HDC hdc) { HDC hdc_work; hdc_work = CreateCompatibleDC(hdc); SelectObject(hdc_work, hb_OilGageback); TransparentBlt(hdc, 10, 11, 320, 50, hdc_work, 0, 0, 320, 50, RGB(0, 0, 255)); SelectObject(hdc_work, hb_OilPower); BitBlt(hdc, 10, 20, Power_w, 35, hdc_work, 0, 0, SRCCOPY); DeleteDC(hdc_work); return 0; }