Spawnova / ShinsImageScanClass

A library/class for fast AutoHotKey image/pixel searching
MIT License
74 stars 12 forks source link

Issue with the PixelRegion Function #12

Closed abnersajr closed 1 year ago

abnersajr commented 1 year ago

Trying to search for a pixel color in a region isn't showing me the right answer. Not sure if there is any offset or I'm not understanding correctly how It's positioned. I took a screenshot using gimp and trimmed the 23px from the top bar. Then I selected the region, When I try to find the pixel in the specific region it doesn't match. Looks like there is a 8 pixels Y offset. Compared to the GetPixel function doesn't match. I made a small fn:

Debugger:
    c := scan.GetPixel(13,12)
    MouseGetPos, mX, mY, , , 1
    if(mX < 0 and mX < 0) {
        return
    }
    actual_c := scan.GetPixel(mX, mY)
    ToolTip, % mX ", " mY "`n Color: " Format("{:X}", actual_c), 0, 0, A
    scan.SaveImage(teste)
    OutputDebug, % Format("{:X}", c)
return

The GetPixel returns as I see in Gimp.

Spawnova commented 1 year ago

When you save the image buffer with scan.SaveImage("image.png") that is exactly what the script sees when it searches, so I would verify it's position using that image.

Also when you initialize the class the second param determines whether it uses window space or client space, by default it uses client which doesn't include the title bar.

I've tried on my end to replicate the issue but I don't see any problems currently, although I did notice that GetPixel returns the alpha channel which may cause issues, so I have updated the class to fix that function.