Thread: TransparentBlt

  1. #1
    rEtaRD r HUMANS TOO !!! rEtard's Avatar
    Join Date
    Feb 2005
    Posts
    80

    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
    /* Have a nice day */

  2. #2
    Registered User jagi's Avatar
    Join Date
    Mar 2005
    Location
    Poland
    Posts
    21
    Try to use HWND as argument of function and then take HDC from HWND...
    [I'm from Poland]
    [Sorry for my English, because I just learn]

  3. #3
    Registered User r1ck0r's Avatar
    Join Date
    Apr 2005
    Location
    UK
    Posts
    30
    you are forgetting to call GetObject() before calling TransparentBlit().
    Include
    Code:
    GetObject(bmpExercising,sizeof(BITMAP),&bm);
    before calling TransparentBlit() and everything will work fine.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. transparentblt
    By h_howee in forum Windows Programming
    Replies: 4
    Last Post: 09-13-2006, 02:10 PM
  2. TransparentBlt()
    By SniperSAS in forum Windows Programming
    Replies: 6
    Last Post: 03-03-2006, 11:17 PM
  3. TransparentBlt error
    By jmd15 in forum Windows Programming
    Replies: 3
    Last Post: 08-29-2005, 08:22 PM
  4. TransparentBlt
    By Trauts in forum Windows Programming
    Replies: 2
    Last Post: 02-27-2003, 07:40 PM