From d9287fbcb6bb62694819bd8f3f0c9a2f1b51018a Mon Sep 17 00:00:00 2001 From: jst Date: Sat, 23 Nov 2013 18:02:18 +0100 Subject: [PATCH] Use x,y as coordinates of the origin image. --- resize.go | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/resize.go b/resize.go index 942c1d3..e78f35c 100644 --- a/resize.go +++ b/resize.go @@ -63,13 +63,13 @@ func Resize(width, height uint, img image.Image, interp InterpolationFunction) i filter := interp(img, float32(clampFactor(scaleX))) var u float32 var color color.RGBA64 - for y := b.Min.X; y < b.Max.X; y++ { - for x := b.Min.Y; x < b.Max.Y; x++ { - u = scaleX*(float32(x)+adjust) + float32(oldBounds.Min.X) + for y := b.Min.Y; y < b.Max.Y; y++ { + for x := b.Min.X; x < b.Max.X; x++ { + u = scaleX*(float32(y)+adjust) + float32(oldBounds.Min.X) - color = filter.Interpolate(u, y) + color = filter.Interpolate(u, x) - i := tempImg.PixOffset(y, x) + i := tempImg.PixOffset(x, y) tempImg.Pix[i+0] = uint8(color.R >> 8) tempImg.Pix[i+1] = uint8(color.R) tempImg.Pix[i+2] = uint8(color.G >> 8) @@ -97,13 +97,13 @@ func Resize(width, height uint, img image.Image, interp InterpolationFunction) i filter := interp(tempImg, float32(clampFactor(scaleY))) var u float32 var color color.RGBA64 - for y := b.Min.X; y < b.Max.X; y++ { - for x := b.Min.Y; x < b.Max.Y; x++ { - u = scaleY*(float32(x)+adjust) + float32(oldBounds.Min.Y) + for y := b.Min.Y; y < b.Max.Y; y++ { + for x := b.Min.X; x < b.Max.X; x++ { + u = scaleY*(float32(y)+adjust) + float32(oldBounds.Min.Y) - color = filter.Interpolate(u, y) + color = filter.Interpolate(u, x) - i := resultImg.PixOffset(y, x) + i := resultImg.PixOffset(x, y) resultImg.Pix[i+0] = uint8(color.R >> 8) resultImg.Pix[i+1] = uint8(color.R) resultImg.Pix[i+2] = uint8(color.G >> 8)