GetPixel and getting a screenshot.
I got the following code in a DLL , also i got another function wrapping getPixel. But i got 2 problems with result i'm getting.
- One is that the image looks more stretched than it should be
- Secondly it doesn't seem to be a 24 bit image, but rather 256 colors
I searched the internet for a solution but couldn't find one. I'm also a bit puzzled on what selectObject really does, msdn is rather vague about it.
Anyone that can help me out with this ?
Code:
HDC doBitmap(HWND hwnd) {
int result;
int height = getHeight(hwnd);
int width = getWidth(hwnd);
HDC hdc = GetWindowDC(hwnd);
if (hdc)
{
HDC hdcMem = CreateCompatibleDC(hdc);
if (hdcMem)
{
HBITMAP hbitmap = CreateCompatibleBitmap(hdc, width,height);
if (hbitmap)
{
SelectObject(hdcMem, hbitmap);
result = PrintWindow(hwnd, hdcMem, 0);
return hdcMem;
}
DeleteObject(hdcMem);
}
ReleaseDC(hwnd, hdc);
}
return 0;
}