Bitmap Transparency in EVC3.0
-
Good day, I have made a class that can display a bitmap with transparance (i.e. display bitmap image except for the unwanted color is not displayed). It works fine in Visual C++. Now i'm porting the class to Embedded VisualC++(EVC3.0) however There is not CDC::SetMapMode in EVC3.0. Anybody knows what is its equivalent? Anyway here is my code in Visual C++, class CMyBitmap derived public from CBitmap and Draw function and has DrawTransparent function... In the code here I've just comment the CDC.SetMapMode code... Anybody have suggestion? Thanks. void CMyBitmap::Draw(CDC *pDC, int x, int y) { BITMAP bm; GetBitmap (&bm); CPoint size (bm.bmWidth, bm.bmHeight); pDC->DPtoLP (&size); CPoint org (0, 0); pDC->DPtoLP (&org); CDC dcMem; dcMem.CreateCompatibleDC (pDC); CBitmap* pOldBitmap = dcMem.SelectObject (this); //dcMem.SetMapMode (pDC->GetMapMode ()); pDC->BitBlt (x, y, size.x, size.y, &dcMem, org.x, org.y, SRCCOPY); dcMem.SelectObject (pOldBitmap); } void CMyBitmap::DrawTransparent(CDC *pDC, int x, int y, COLORREF clrTransparency) { BITMAP bm; GetBitmap (&bm); CPoint size (bm.bmWidth, bm.bmHeight); pDC->DPtoLP (&size); CPoint org (0, 0); pDC->DPtoLP (&org); CDC dcImage; dcImage.CreateCompatibleDC (pDC); CBitmap* pOldBitmapImage = dcImage.SelectObject (this); //dcImage.SetMapMode (pDC->GetMapMode ()); CDC dcAnd; dcAnd.CreateCompatibleDC (pDC); //dcAnd.SetMapMode (pDC->GetMapMode ()); CBitmap bitmapAnd; bitmapAnd.CreateBitmap (bm.bmWidth, bm.bmHeight, 1, 1, NULL); CBitmap* pOldBitmapAnd = dcAnd.SelectObject (&bitmapAnd); dcImage.SetBkColor (clrTransparency); dcAnd.BitBlt (org.x, org.y, size.x, size.y, &dcImage, org.x, org.y, SRCCOPY); CDC dcXor; dcXor.CreateCompatibleDC (pDC); //dcXor.SetMapMode (pDC->GetMapMode ()); CBitmap bitmapXor; bitmapXor.CreateCompatibleBitmap (&dcImage, bm.bmWidth, bm.bmHeight); CBitmap* pOldBitmapXor = dcXor.SelectObject (&bitmapXor); dcXor.BitBlt (org.x, org.y, size.x, size.y, &dcImage, org.x, org.y, SRCCOPY); dcXor.BitBlt (org.x, org.y, size.x, size.y, &dcAnd, org.x, org.y, 0x220326); CDC dcTemp; dcTemp.CreateCompatibleDC (pDC); //dcTemp.SetMapMode (pDC->GetMapMode ()); CBitmap bitmapTemp; bitmapTemp.CreateCompatibleBitmap (&dcImage, bm.bmWidth, bm.bmHeight); CBitmap* pOldBitmapTemp = dcTemp.SelectObject (&bitmapTemp)