Your question, your audience. Choose who sees your identity—and your question—with question security.
Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.
Have a better answer? Share it in a comment.
From novice to tech pro — start learning today.
it draw a bitmap with a colour defined transparent
void DrawTransparent(CDC * pDC, CBitmap *pThisBmp, int x, int y, int W, int H, int nWidth, int nHeight, COLORREF crColour, CPalette* Palette)
{
CBitmap & ThisBmp = *pThisBmp;
COLORREF crOldBack = pDC->SetBkColor(RGB(255,25
COLORREF crOldText = pDC->SetTextColor(RGB(0,0,
CDC dcImage, dcTrans;
// Create two memory dcs for the image and the mask
dcImage.CreateCompatibleDC
dcTrans.CreateCompatibleDC
// Select the image into the appropriate dc
CBitmap* pOldBitmapImage = (CBitmap*)dcImage.SelectOb
if (Palette)
{
dcImage.SelectPalette(Pale
}
// Create the mask bitmap
CBitmap bitmapTrans;
bitmapTrans.CreateBitmap(n
// Select the mask bitmap into the appropriate dc
CBitmap* pOldBitmapTrans = dcTrans.SelectObject(&bitm
// Build mask based on transparent colour
dcImage.SetBkColor(crColou
dcTrans.BitBlt(0, 0, nWidth, nHeight, &dcImage, 0, 0, SRCCOPY);
// Do the work - True Mask method - cool if not actual display
pDC->SetStretchBltMode( COLORONCOLOR);
pDC->StretchBlt( x, y, W, H, &dcImage, 0, 0, nWidth, nHeight, SRCINVERT );
pDC->StretchBlt( x, y, W, H, &dcTrans, 0, 0, nWidth, nHeight, SRCAND );
pDC->StretchBlt( x, y, W, H, &dcImage, 0, 0, nWidth, nHeight, SRCINVERT );
// Restore settings
dcImage.SelectObject(pOldB
dcTrans.SelectObject(pOldB
pDC->SetBkColor(crOldBack)
pDC->SetTextColor(crOldTex
}