SolvedPixel Scanning

Posts 1–8 of 8 · Page 1 of 1
Pixel Scanning
Code:
	__declspec(dllexport) XYCOORD pxscan(HWND hwnd, DWORD color, RECT region, unsigned short skip, unsigned tolerance)
	{
		RECT rect;
		GetWindowRect(hwnd, &rect);
		HDC hDC = GetDC(hwnd);
		for(int i = region.left + rect.left; i <= (region.right + rect.left); i += skip)
		{
			for(int n = region.top + rect.top; n <= region.top - rect.bottom; n += skip)
			{
				DWORD c = GetPixel(hDC, i, n);
				if(abs(c - color) <= tolerance)
				{
					XYCOORD coord;
					coord.x = i;
					coord.y = n;
					return coord;
				}
			}
		}
		XYCOORD failed;
		failed.x = -1;
		failed.y = -1;
		return failed;
	}
Never works... I call it like
Code:
XYCOORD auto_setup = pxscan(client, 0x202020, a, 1, 5);
But it always fails.. can anyone help? I use the color I get from a hex color picker (0x202020)...
That translates into 0x00202020, which is a different color then you're scanning for
use the RGB macro to construct a color: RGB(32, 32, 32) in your case
I did some error checking and the function always returns CLR_INVALID.
Im scanning a child java frame window that I had to SetParent to my window.
Can I pm you the whole project? Im getting frusturated
It sounds like you're going outside of the window clipping area then.
Use ScreenToClient to convert to client coordinates and then do some size checking.
Also, pixel scanning like that is pretty slow, a fast way would be to capture a part of the screen and scan the pixels from the captured image.
ya kibbles, listen to what master said. i ran into this problem like 2 years ago. it was so slow, so i ended up making 64 threads that run simultaneously via createthread, and let me just tell u that my computer was never the same again lol.
It's not THAT bad if you skip every second pixel :\ granted it's not as fast as certain other methods but it's fast enough for most things X:
I fixed it. Now im looking to upgrade. Anyone have any sample code of using Dib to scan?
Posts 1–8 of 8 · Page 1 of 1

Post a Reply

Similar Threads

Tags for this Thread

None

Need help?