sir, i had try to convert the above code. but this code doesn't work at all. please check it.
COLORREF m_crBlack;
COLORREF m_crWhite;
int Height();
int Width();
void InitBMP();
void DrawTransparent(HDC* pDC, int x, int y, COLORREF crColour);
void InitBMP()
{
m_crBlack = 0;
m_crWhite = RGB(255,255,255);
}
int Width()
{
BITMAP bm={0};
//SIZE lp ={0};
//GetBitmapDimensionEx(bm,&lp);
//return lp.cx;
GetObject(&bm,sizeof(BITMAP),&bm);
return bm.bmWidth;
}
int Height()
{
BITMAP bm={0};
//SIZE lp={0};
//GetBitmapDimensionEx(bm,&lp);
//return lp.cy;
GetObject(&bm, sizeof(BITMAP),&bm);
return bm.bmHeight;
}
void DrawTransparent(HDC pDC, int x, int y, COLORREF crColour)
{
COLORREF croldBack = SetBkColor(pDC,m_crWhite);
COLORREF croldText = SetTextColor(pDC,m_crBlack);
//create two memory dcs for the image and the mask;
HDC dcImage = CreateCompatibleDC(pDC);
HDC dcTrans = CreateCompatibleDC(pDC);
//Select the image into the appropriate dc
HBITMAP pOldBitmapImage = NULL;
SelectObject(dcImage,pOldBitmapImage);
//SelectObject(dcImage,this);
//create the mask bitmap
HBITMAP bitmapTrans = NULL;
int nWidth = Width();
int nHeight =Height();
bitmapTrans = CreateBitmap(nWidth,nHeight,1,1,NULL);
//select the mast bitmap into the appropriate dc
HBITMAP pOldBitmapTrans= NULL;
SelectObject(dcTrans,bitmapTrans);
//Build mask based on transparent color
SetBkColor(dcImage,crColour);
BitBlt(dcTrans,0,0,nWidth,nHeight,dcImage,0,0,SRCCOPY);
//Do the work true mask method
BitBlt(pDC,x,y,nWidth,nHeight,dcImage,0,0,SRCINVERT);
BitBlt(pDC,x,y,nWidth,nHeight,dcTrans,0,0,SRCAND);
BitBlt(pDC,x,y,nWidth,nHeight,dcImage,0,0,SRCINVERT);
//Restore Settings
SelectObject(dcImage,pOldBitmapImage);
SelectObject(dcTrans,pOldBitmapTrans);
SetBkColor(pDC,croldBack);
SetTextColor(pDC,croldText);
}
Some Day I Will Prove MySelf :: GOLD