hi all:-)
I have the following question:
I have two CBitMap objects, which represent 2 .png-Files.
Now i want to overlay them the following way, where the 2nd cbitmap is over the first Bitmap:
if a pixel of the 2nd cbitmap is white, i want to display the pixel of the first cbitmap. if it is not white, i want to display the pixel of the 2nd cbitmap.
Is this possible to achieve?
I tried it with the Alphablend() function, where i set the alpha-value of the white pixels of the 2nd cbitmap to zero.
Always, only the second png is displayed...
Any ideas?
Thanks for any help!
[edit]
Here is my code, for future visitors:
void PngImage::DrawOverlayedBitmap(CBitmap* pBitmapUnder, CBitmap* pBitmapUpper, CWnd* pWnd, CPoint Offset)
{
BITMAP bmpInfo;
pBitmapUnder->GetObject(sizeof(bmpInfo), &bmpInfo);
CSize size;
size.cx = bmpInfo.bmWidth;
size.cy = bmpInfo.bmHeight;
CClientDC* pDC = new CClientDC(pWnd);
CDC* memDC = new CDC; memDC->CreateCompatibleDC(pDC);
CBitmap* old = memDC->SelectObject(pBitmapUnder);
pDC->BitBlt
(
Offset.x, Offset.y, size.cx, size.cy, memDC, 0, 0, SRCCOPY );
memDC->SelectObject(pBitmapUpper);
pDC->BitBlt
(
Offset.x, Offset.y, size.cx, size.cy, memDC, 0, 0, SRCAND );
delete memDC; memDC = 0;
delete pDC; pDC = 0;
}
[/edit]