// JP opened flex table

Click to See Complete Forum and Search --> : SRCAND transparency


jigen3
November 18th, 2003, 12:33 AM
hi,
does anyone know the blitting routines needed to display transparency with the net result being SRCAND of the original? SRCCOPY transparency is:


dcOriginal.SetBkColor(crColor); //crcolor is trans. color
dcTrans.BitBlt(0, 0, nWidth, nHeight, &dcOriginal, 0, 0, SRCCOPY);


pDC->BitBlt(x, y, nWidth, nHeight, &dcOriginal, 0, 0, SRCINVERT);
pDC->BitBlt(x, y, nWidth, nHeight, &dcTrans, 0, 0, SRCAND);
pDC->BitBlt(x, y, nWidth, nHeight, &dcOriginal, 0, 0, SRCINVERT);


thx
jigen3

Caprice
November 27th, 2003, 10:10 AM
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
);

Requirements
Windows NT/2000/XP: Included in Windows 2000 and later.
Windows 95/98/Me: Included in Windows 98 and later.
Header: Declared in Wingdi.h; include Windows.h.
Library: Use Msimg32.lib.

if that's not enough I can find and send you the old-fashion functions you asked.

Take a look:
http://www.codeguru.com/bitmap/CISBitmap.shtml

jigen3
November 29th, 2003, 02:08 PM
thx for the reply, i tried your suggestion, but everything just came out white, background and foreground, not transparent...hmm.

Caprice
November 29th, 2003, 02:58 PM
What are you talking about?

void CSimpleTransparentDlg::DrawBitmap(HDC hDC)
{
CBitmap bm;
bm.LoadBitmap(IDB_BITMAP1);

BITMAP bitmap = { 0 };
bm.GetBitmap(&bitmap);

HDC hMemDC = CreateCompatibleDC(hDC);
HBITMAP hBitmapOld = (HBITMAP)SelectObject(hMemDC, (HBITMAP)bm);
COLORREF clrTransp = GetPixel(hMemDC, 0, 0);

TransparentBlt(hDC, 20, 20, bitmap.bmWidth, bitmap.bmHeight,
hMemDC, 0, 0, bitmap.bmWidth, bitmap.bmHeight, clrTransp);

SelectObject(hMemDC, hBitmapOld);
DeleteDC(hMemDC);
}

and in the project settings you need to add Msimg32.lib

Take a look the attached project.

jigen3
November 29th, 2003, 03:32 PM
oops sorry i had a value wrong, was using the wrong dc. the net result tho is not a SRCAND copy, it is still a SRCCOPY in the end: the bitmap (that has been made transparent) overwrites any other color information already present on the dc. thx tho for telling me about this function.

jigen3

//JP added flex table