1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
|
int get_Bitmap(int GxpSx, int GypSy, HDC& hdcMemory, int width, int height) {
HDC hdcSource = GetDC(NULL);
hdcMemory = CreateCompatibleDC(hdcSource);
HBITMAP hBitmap = CreateCompatibleBitmap(hdcSource, width, height);
HBITMAP hBitmapOld = (HBITMAP)SelectObject(hdcMemory, hBitmap);
if (!BitBlt(hdcMemory, 0, 0, width, height, hdcSource, GxpSx, GypSy, CAPTUREBLT | SRCCOPY)) {
cout << "BitBlt failed!" << endl;
cout << GetLastError() << endl;
}
//clean up
DeleteObject(hBitmapOld);
DeleteObject(hBitmap);
ReleaseDC(NULL, hdcSource);
return 0;
}
void function_F(POINT GWindowO, POINT PS_Full, POINT status_bar, HDC& hcdMemory) {
get_Bitmap(GWindowO.x, GWindowO.y, ref(hdcMemory), 432, 934);
PS_status = GetPixel(hdcMemory, PS_Full.x, PS_Full.y);
PS_status2 = GetPixel(hdcMemory, PS_Full.x - 100, PS_Full.y);
caught_indc = GetPixel(hdcMemory, 216, 784);
YS_Status = GetPixel(hdcMemory, status_bar.x, status_bar.y);
}
int main() {
HDC hdcMemory = NULL;
function(GWindowO, PS_Full, status_bar, ref(hcdMemory));
}
|