你查查函数,使一张位图的背景色透明BOOL TransparentBlt( HDC hdcDest, // handle to destination DC int nXOriginDest, // x-coord of destination upper-left corner int nYOriginDest, // y-coord of destination upper-left corner int nWidthDest, // width of destination rectangle int hHeightDest, // height of destination rectangle HDC hdcSrc, // handle to source DC int nXOriginSrc, // x-coord of source upper-left corner int nYOriginSrc, // y-coord of source upper-left corner int nWidthSrc, // width of source rectangle int nHeightSrc, // height of source rectangle UINT crTransparent // color to make transparent );给你个例子:CDC *pDC = GetDC(); CBitmap bmp; bmp.LoadBitmap(IDB_BITMAP5); CDC MemDC; MemDC.CreateCompatibleDC(pDC); MemDC.SelectObject(&bmp); BITMAP bmpInfo; bmp.GetBitmap(&bmpInfo); //使背景透明 TransparentBlt(pDC->m_hDC, 0, 0, bmpInfo.bmWidth, bmpInfo.bmHeight, MemDC.m_hDC, 0, 0, bmpInfo.bmWidth, bmpInfo.bmHeight, RGB(255, 0, 255));
HDC hdcDest, // handle to destination DC
int nXOriginDest, // x-coord of destination upper-left corner
int nYOriginDest, // y-coord of destination upper-left corner
int nWidthDest, // width of destination rectangle
int hHeightDest, // height of destination rectangle
HDC hdcSrc, // handle to source DC
int nXOriginSrc, // x-coord of source upper-left corner
int nYOriginSrc, // y-coord of source upper-left corner
int nWidthSrc, // width of source rectangle
int nHeightSrc, // height of source rectangle
UINT crTransparent // color to make transparent
);给你个例子:CDC *pDC = GetDC();
CBitmap bmp;
bmp.LoadBitmap(IDB_BITMAP5);
CDC MemDC;
MemDC.CreateCompatibleDC(pDC);
MemDC.SelectObject(&bmp);
BITMAP bmpInfo;
bmp.GetBitmap(&bmpInfo);
//使背景透明
TransparentBlt(pDC->m_hDC, 0, 0, bmpInfo.bmWidth, bmpInfo.bmHeight, MemDC.m_hDC, 0, 0,
bmpInfo.bmWidth, bmpInfo.bmHeight, RGB(255, 0, 255));