iseahound / ImagePut

A core library for images in AutoHotkey. Supports AutoHotkey v1 and v2.
https://www.autohotkey.com/boards/viewtopic.php?f=83&t=76633
MIT License
124 stars 26 forks source link

Pixel Inflation #32

Closed iseahound closed 1 year ago

iseahound commented 1 year ago

Current implementation of SSE2 causes pixels to be double or triple counted.

Only occurs when the number of side by side colors is more than 3:

#include *i ImagePut%A_TrayMenu%.ahk
#include *i ImagePut (for v%true%).ahk
#singleinstance force

pic := ImagePutBuffer("d.png")     ; Load image
pic.show() ; or ImageShow(pic)                         ; Show image
if xys := pic.PixelSearchAll([0xED1C24, 1, 2, 0x000000]) {                    ; Get [x, y] of 0xFFFFFF
    MouseMove(xys[1]*)                             ; Move cursor
    Send "{MButton}"
    MsgBox xys.length
}
else Reload                                            ; Restart

for the image: https://github.com/iseahound/ImagePut/assets/9779668/9d3c78a9-5ba5-4e3a-b178-c0616966a0fe

The solutions are here: pixelsearchall3: https://godbolt.org/z/evaxq93fd pixelsearch3: https://godbolt.org/z/drTev8Kx3

In addition: optimizations have also been made such that the SIMD instructions exist one after the other, which produced a 20% increase in speed in my testing.

iseahound commented 1 year ago

Fixed by 33c2a9a2d94f39f1fc1b0e464903fa63bc5d6afd