-
July 21st, 2010, 09:24 AM
#1
Am I BitBlt'ing Bitmap correctly? wrong code?
Im trying to replace my gdi+ DrawImage() code to BitBlt'ing code to speed things up but my image won't paint to the screen?
Is this the correct code? thanks.
hdc = BeginPaint (hWnd, &ps);
HDC hdcMem = CreateCompatibleDC(hdc);
SelectObject(hdcMem, myBitmap);
BitBlt(hdc, 0, 0, myBitmap->GetWidth(), myBitmap->GetHeight(), hdcMem, 0, 0, SRCCOPY);
DeleteDC(hdcMem);
When I was using DrawImage() everything was fine. but too slow.
Im really am sure this is not the right code.
-
July 25th, 2010, 12:08 PM
#2
Re: Am I BitBlt'ing Bitmap correctly? wrong code?
Where is "MyBitmap" defined/initialized?
-
July 29th, 2010, 10:09 PM
#3
Re: Am I BitBlt'ing Bitmap correctly? wrong code?
Did the OP call EndPaint()?
-
July 30th, 2010, 07:28 AM
#4
Re: Am I BitBlt'ing Bitmap correctly? wrong code?
In SelectObject, you have to pass a HBITMAP handle and not a pointer to Gdiplus::Bitmap object.
Code:
//...
HDC hdcMem = ::CreateCompatibleDC(hdc);
HBITMAP hBitmap = NULL;
Color color;
myBitmap->GetHBITMAP(color, &hBitmap);
HBITMAP hBitmapOld = (HBITMAP)::SelectObject(hdcMem, hBitmap);
::BitBlt(hdc, 0, 0, myBitmap->GetWidth(), myBitmap->GetHeight(), hdcMem, 0, 0, SRCCOPY);
::SelectObject(hdcMem, hBitmapOld);
::DeleteDC(hdcMem);
// ...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|