Below code draws a transparent bitmap perfectly but when i change size of the bitmap on screen, transparency is gone. This code is only drawing original bitmap size(80 X 80) as transparent but not able draw transparency properly when i resize(90 X 90) bitmap on screen. Can anybody pin point the problem in the code. Thank you in advance for help.
void CPictureManager::TransparentBitmap(CDC* pDC,CBitmap *pBitmap, CRect render,int iSrcWidth,int iSrcHeight,COLORREF clrpTransColor)
{
CDC dcTemp;
dcTemp.CreateCompatibleDC(pDC);
CBitmap* bmTemp = dcTemp.SelectObject(pBitmap);
BITMAP bm;
pBitmap->GetBitmap(&bm);
POINT ptSize;
ptSize.x = bm.bmWidth; ptSize.y = bm.bmHeight; dcTemp.DPtoLP(&ptSize, 1);
CDC dcMem;
dcMem.CreateCompatibleDC(pDC);
CDC dcBack;
dcBack.CreateCompatibleDC(pDC);
CDC dcObject;
dcObject.CreateCompatibleDC(pDC);
CDC dcSave;
dcSave.CreateCompatibleDC(pDC);
CBitmap bmAndBack;
bmAndBack.CreateBitmap(ptSize.x,ptSize.y,1,1,NULL);
CBitmap bmAndObject;
bmAndObject.CreateBitmap(ptSize.x,ptSize.y,1,1,NULL);
CBitmap bmAndMem;
bmAndMem.CreateCompatibleBitmap(pDC,ptSize.x,ptSize.y);
CBitmap bmSave;
bmSave.CreateCompatibleBitmap(pDC,ptSize.x,ptSize.y);
CBitmap* bmBackOld = (CBitmap*)dcBack.SelectObject(&bmAndBack);
CBitmap* bmObjectOld = (CBitmap*)dcObject.SelectObject(&bmAndObject);
CBitmap* bmMemOld = (CBitmap*)dcMem.SelectObject(&bmAndMem);
CBitmap* bmSaveOld = (CBitmap*)dcSave.SelectObject(&bmSave);
dcTemp.SetMapMode(pDC->GetMapMode());
dcSave.BitBlt(0,0,ptSize.x,ptSize.y,&dcTemp,0,0,SRCCOPY);
COLORREF cColor;
cColor = dcTemp.SetBkColor(clrpTransColor);
dcObject.BitBlt(0,0,ptSize.x,ptSize.y,&dcTemp,0,0,SRCCOPY);
dcTemp.SetBkColor(cColor);
dcBack.BitBlt(0,0,ptSize.x,ptSize.y,&dcObject,0,0,NOTSRCCOPY);
dcMem.BitBlt(0,0,ptSize.x,ptSize.y,pDC,render.left,render.top,SRCCOPY);
dcMem.BitBlt(0,0,ptSize.x,ptSize.y,&dcObject,0,0,SRCAND);
dcTemp.BitBlt(0,0,ptSize.x,ptSize.y,&dcBack,0,0,SRCAND);
dcMem.BitBlt(0,0,ptSize.x,ptSize.y,&dcTemp,0,0,SRCPAINT);
pDC->StretchBlt(render.left,render.top,render.Width(),render.Height(),&dcMem,0,0,iSrcWidth,iSrcHeight,SRCCOPY);
dcTemp.BitBlt(0,0,ptSize.x,ptSize.y,&dcSave,0,0,SRCCOPY);
dcBack.SelectObject(bmBackOld);
dcObject.SelectObject(bmObjectOld);
dcMem.SelectObject(bmMemOld);
dcSave.SelectObject(bmSaveOld);
dcTemp.SelectObject(bmTemp);
}