anthonynsimon / bild

Image processing algorithms in pure Go
MIT License
3.99k stars 213 forks source link

Fix wrong bounds usage, switched to size deltas #8

Closed anthonynsimon closed 8 years ago

anthonynsimon commented 8 years ago

Using image.bounds().Max.X or Y causes the Pix traversal to run out of bounds. Now using image.bounds().Dx() or Dy() for all cases.

This is because if an image rectangle has a non-zero starting point bounds (such as 1,1-3,3 for a 2x2 image), then the bounds().Max would return 3 as length for X and Y instead of 2. So the delta is what is really needed.