I want to screen capture a specific window (I can locate the window) and hold the capture in memory until I can get the data I need from it (finding if the image contains another image). I have tried using BitBlt, it has some strange effects on my screen, but I don't know how or where to access the bitmap it has in memory. I've been searching on google for the past 2 hours for some help on this, and still don't understand how to do this. If someone could please explain, it would be much appreciated, thanks.
How I capture my window: cout << BitBlt(GetDC(NULL), rect.left, rect.top, rect.right, rect.bottom, GetWindowDC(NULL), 0, 0, SRCCOPY);
You need to create an offscreen DC which holds the image.
1 2 3 4 5 6 7 8 9 10 11 12 13 14
HDC mdc = CreateCompatibleDC(NULL);
HBITMAP bmp = CreateBitmap( width, height, 1, 32, NULL );
HBITMAP bmpold = (HBITMAP)SelectObject(mdc,bmp);
// BitBlt from your source window's DC to 'mdc'
// examine 'mdc' by way of GetDIBits, GetPixel, or whatever other function
// you want. Alternatively, you can use CreateDIBSection instead of
// createBitmap to get a raw pointer to pixel data and work with that.
// when done....