Quote (rockonkenshin @ 9 Nov 2009 17:50)
For an in memory comparison I'm not sure, I'd also have to google it.
Well honestly, if you had the one image you'd like to compare written out in an array, you could use GetPixel or GetGDI.. forget what it was (GetDCLine() or something similar) and compare one by one until you find a mis-match.
You can capture images via Window's GDI through this method:
http://msdn.microsoft.com/en-us/library/dd183402(VS.85).aspx but, there's nothing about comparing images.
Or this:
Code
void ScreenShot() {
HDC hdcScreen, hdcMemory;
int cxScreen, cyScreen;
HBITMAP hbmMemory, hbmOld;
BITMAPINFO bi;
void* data;
// get the HDC of the screen
hdcScreen = GetDC(NULL);
// get the screen size
cxScreen = GetSystemMetrics(SM_CXSCREEN) / 10;
cyScreen = GetSystemMetrics(SM_CYSCREEN) / 10;
// create a compatible memory dc/bitmap pair
hdcMemory = CreateCompatibleDC(hdcScreen);
hbmMemory = CreateCompatibleBitmap(hdcScreen, cxScreen, cyScreen);
hbmOld = (HBITMAP)SelectObject(hdcMemory, hbmMemory);
// "capture" the screen into this pair
BitBlt(hdcMemory, 0, 0, cxScreen, cyScreen, hdcScreen, 0, 0, SRCCOPY);
// now that we got the screen into the HBITMAP, get its bits
// we want to get it as 24-bpp
ZeroMemory(&bi, sizeof(BITMAPINFO));
bi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
bi.bmiHeader.biWidth = cxScreen;
bi.bmiHeader.biHeight = cyScreen;
bi.bmiHeader.biBitCount = 24;
bi.bmiHeader.biPlanes = 1;
// first call with a NULL pointer to fill in rest of bi.bmiHeader
GetDIBits(hdcMemory, hbmMemory, 0, cyScreen, NULL, &bi, DIB_RGB_COLORS);
// allocate memory (size is in bi.bmiHeader.biSizeImage)
data = malloc(bi.bmiHeader.biSizeImage);
// now get the data
GetDIBits(hdcMemory, hbmMemory, 0, cyScreen, data, &bi, DIB_RGB_COLORS);
// clean-up
SelectObject(hdcMemory, hbmOld);
DeleteDC(hdcMemory);
DeleteObject(hbmMemory);
return;
}
But even then, I'm unsure of how to access the image like that.
If I knew how to loop through the bits in the image, and one that's stored on the harddrive, that'd be great.
This post was edited by Muted on Nov 9 2009 06:02pm