我目前正在寻找一种方法来访问和测试从目标窗口复制的位图的各个像素,而不使用非常慢的GetPixel()
方法。鉴于memDC
在调用时包含位图的副本BitBlt()
,是否有更快的方法来遍历单个像素并测试它们的值?
HWND target = (HWND)0x0002051A; // this is just for debugging; when i get to the release version it will detect the intended window automatically
HBITMAP hBitmap;
RECT winRect;
HDC winDC, memDC;
winDC = GetDC(target);
GetClientRect(target, &winRect);
memDC = CreateCompatibleDC(winDC);
hBitmap = CreateCompatibleBitmap(winDC, winRect.right-winRect.left, winRect.bottom-winRect.top);
SelectObject(memDC, hBitmap);
BitBlt(memDC, 0, 0, winRect.right-winRect.left, winRect.bottom-winRect.top, winDC, 0, 0, SRCCOPY);
// Perform other tasks based on the color values of pixels...
ReleaseDC(memDC);
ReleaseDC(winDC);
DeleteObject(hBitmap);