nfnt / resize

Pure golang image resizing
ISC License
3.02k stars 321 forks source link

Fix to resize correctly when source image.Bounds().Min is not (0,0) #14

Closed anisus closed 10 years ago

anisus commented 10 years ago

Resizing an image with image.Bounds().Min not being (0,0) caused undesired effects. This small change will add Min.Y as offset when calling filter.Interpolate()

The second round of resize has the xoffset, yoffset set to 0, 0 because it is them operating on the tempImg that has tempImg.Bounds().Min being (0,0).

The bug was noticed when doing a resize.Resize() after using rgbaimage.SubImage()

Before fix: 539e66d6726fbf1a18000001

After fix: (with a slightly different SubImage Rectangle, but you get the point) 539e68d4726fbf192c000001

nfnt commented 10 years ago

Thanks for finding this one. Seems to have sneaked in during a large change and I haven't checked for working SubImage after that. I'll write a unit test to cover that case.