在这之前背景贴了张jpg, 然后在jpg上贴位图
贴位图的代码如下 bmp.LoadBitmap(IDB_BITMAP2);
bmp.GetBitmap(&bmpInfo);
// Create an in-memory DC compatible with the
// display DC we're using to paint
CDC dcMemory;
dcMemory.CreateCompatibleDC(pDC); // Select the bitmap into the in-memory DC
CBitmap* pOldBitmap = dcMemory.SelectObject(&bmp); // Find a centerpoint for the bitmap in the client area
CRect rect;
GetClientRect(&rect);
ti[i].x +=10;
int nX = ti[i].x;
int nY = ti[i].y ; // Copy the bits from the in-memory DC into the on-
// screen DC to actually do the painting. Use the centerpoint
// we computed for the target offset.
pDC->BitBlt(nX, nY, bmpInfo.bmWidth, bmpInfo.bmHeight, &dcMemory,
0, 0, SRCAND); dcMemory.SelectObject(pOldBitmap); 请问为何 ?
贴位图的代码如下 bmp.LoadBitmap(IDB_BITMAP2);
bmp.GetBitmap(&bmpInfo);
// Create an in-memory DC compatible with the
// display DC we're using to paint
CDC dcMemory;
dcMemory.CreateCompatibleDC(pDC); // Select the bitmap into the in-memory DC
CBitmap* pOldBitmap = dcMemory.SelectObject(&bmp); // Find a centerpoint for the bitmap in the client area
CRect rect;
GetClientRect(&rect);
ti[i].x +=10;
int nX = ti[i].x;
int nY = ti[i].y ; // Copy the bits from the in-memory DC into the on-
// screen DC to actually do the painting. Use the centerpoint
// we computed for the target offset.
pDC->BitBlt(nX, nY, bmpInfo.bmWidth, bmpInfo.bmHeight, &dcMemory,
0, 0, SRCAND); dcMemory.SelectObject(pOldBitmap); 请问为何 ?
1.SRCAND应该改为SRCCOPY;
2.图片复制时的坐标位置,由
ti[i].x +=10;
int nX = ti[i].x;
int nY = ti[i].y ;
确定,在x方向有10的偏移-----这是为什么你发现贴上去了,但仍然看到背景的原因.