-
TransparentBlt
Can someone tell me where did i do wrong with TransparentBlt, i always get an error no matter how i change it.
Code:
void Bitmap(HDC hDC, HINSTANCE hInst, HWND hwnd)
{
BITMAP bm;
HDC MemDCExercising;
HBITMAP bmpExercising;
bmpExercising = LoadBitmap(hInst, MAKEINTRESOURCE(IDB_BITMAP3));
MemDCExercising = CreateCompatibleDC(hDC);
SelectObject(MemDCExercising, bmpExercising);
if ( !TransparentBlt(hDC,0,0,bm.bmWidth, bm.bmHeight, MemDCExercising, 0, 0, bm.bmWidth, bm.bmHeight, RGB(0,0,0)))
MessageBox(hwnd, "ERROR","ERROR", MB_OKCANCEL);
DeleteDC(MemDCExercising);
DeleteObject(bmpExercising);
}
the picture im using is a smiley face in a black background
-
Try to use HWND as argument of function and then take HDC from HWND...
-
you are forgetting to call GetObject() before calling TransparentBlit().
Include
Code:
GetObject(bmpExercising,sizeof(BITMAP),&bm);
before calling TransparentBlit() and everything will work fine.