Bitmaps, from handles (HBitmap, Hbmp)
Posted on 2004-04-14
Aright, I need sample code for this, as I am through beating my head against the wall, and not getting it.
Background: I'm injecting a Paint Hook dll into a process, to grab the window before it is scaled.
What I need:
Working, unmanaged, C++ code that can create a Bitmap. I do not care what kind, because it is going into C# land, I can manipulate it from there.
Here a portion of the code :
HBITMAP hBmp = NULL;
HDC hDC = GetDC(hWnd);
hBmp = CreateCompatibleBitmap(hDC, rect.right - rect.left, rect.bottom - rect.top);
hOld = SelectObject(hDCMem, hBmp);
I need a bitmap created from hBmp. And this code is going into a DLL.
I want headers, prototypes, whatever, give it all to me as long as it works.