This code draws a bitmap to the screen with the transparent color skipped. It sort of works, except the background shows through the image as shown in the attachment. Also, a red border is drawn between two sprites when two sprites are drawn over each other.
What's wrong with my code this time?
Code:int DrawSprite(HDC hdc, HBITMAP hbmColour,int x, int y, COLORREF crTransparent) { HDC hdcMem, hdcMem2; HBITMAP hbmMask, hOldBitmap, hOldBitmap2; BITMAP bm; GetObject(hbmColour, sizeof(BITMAP), &bm); hbmMask = CreateBitmap(bm.bmWidth, bm.bmHeight, 1, 1, NULL); hdcMem = CreateCompatibleDC(hdc); hdcMem2 = CreateCompatibleDC(hdc); hOldBitmap = SelectObject(hdcMem, hbmColour); hOldBitmap2 = SelectObject(hdcMem2, hbmMask); SetBkColor(hdcMem, crTransparent); BitBlt(hdcMem2, 0, 0, bm.bmWidth, bm.bmHeight, hdcMem, 0, 0, SRCCOPY); BitBlt(hdcMem, 0, 0, bm.bmWidth, bm.bmHeight, hdcMem2, 0, 0, SRCINVERT); BitBlt(hdc, x, y, bm.bmWidth, bm.bmHeight, hdcMem2, 0, 0, SRCAND); BitBlt(hdc, x, y, bm.bmWidth, bm.bmHeight, hdcMem, 0, 0, SRCPAINT); SelectObject(hdcMem, hOldBitmap); SelectObject(hdcMem2, hOldBitmap2); DeleteDC(hdcMem); DeleteDC(hdcMem2); DeleteObject(hbmMask); return 0; }



LinkBack URL
About LinkBacks





