msanders/autopy — Issue #29: off by 1 in bitmap finding
Author: behrisch
Created: 2011-12-28 18:08:49+00:00
State: open

The coordinates of bitmaps found are always off by one in x and y direction,
best illustrated by the following code:
ARROW = autopy.bitmap.Bitmap.open("arrows.png")
print ARROW.find_bitmap(ARROW)
results in (1,1) instead of the expected (0,0) possibly due to
findBitmapInRectAt, which does 8ofr an unknown reason)
increment the point offset before return:
if (needleAtOffset(needle, haystack, pointOffset, tolerance)) {
++pointOffset.x;
++pointOffset.y;
*point = pointOffset;
return 0;

this has the additional side effect, that the find all bitmaps code does not work properly since it does not find identical bitmaps with the same y coordinate because it starts looking at the coordinates returned by the code above.