|
@@ -61,7 +61,7 @@ func Resize(width, height uint, img image.Image, interp InterpolationFunction) i
|
61
|
61
|
c := make(chan int, n)
|
62
|
62
|
for i := 0; i < n; i++ {
|
63
|
63
|
slice := image.Rect(b.Min.X, b.Min.Y+i*(b.Dy())/n, b.Max.X, b.Min.Y+(i+1)*(b.Dy())/n)
|
64
|
|
- go resizeSlice(img, tempImg, interp, scaleX, adjust, float32(oldBounds.Min.X), slice, c)
|
|
64
|
+ go resizeSlice(img, tempImg, interp, scaleX, adjust, float32(oldBounds.Min.X), oldBounds.Min.Y, slice, c)
|
65
|
65
|
}
|
66
|
66
|
for i := 0; i < n; i++ {
|
67
|
67
|
<-c
|
|
@@ -73,7 +73,7 @@ func Resize(width, height uint, img image.Image, interp InterpolationFunction) i
|
73
|
73
|
|
74
|
74
|
for i := 0; i < n; i++ {
|
75
|
75
|
slice := image.Rect(b.Min.X, b.Min.Y+i*(b.Dy())/n, b.Max.X, b.Min.Y+(i+1)*(b.Dy())/n)
|
76
|
|
- go resizeSlice(tempImg, resultImg, interp, scaleY, adjust, float32(oldBounds.Min.Y), slice, c)
|
|
76
|
+ go resizeSlice(tempImg, resultImg, interp, scaleY, adjust, 0, 0, slice, c)
|
77
|
77
|
}
|
78
|
78
|
for i := 0; i < n; i++ {
|
79
|
79
|
<-c
|
|
@@ -83,15 +83,15 @@ func Resize(width, height uint, img image.Image, interp InterpolationFunction) i
|
83
|
83
|
}
|
84
|
84
|
|
85
|
85
|
// Resize a rectangle image slice
|
86
|
|
-func resizeSlice(input image.Image, output *image.RGBA64, interp InterpolationFunction, scale, adjust, offset float32, slice image.Rectangle, c chan int) {
|
|
86
|
+func resizeSlice(input image.Image, output *image.RGBA64, interp InterpolationFunction, scale, adjust, xoffset float32, yoffset int, slice image.Rectangle, c chan int) {
|
87
|
87
|
filter := interp(input, float32(clampFactor(scale)))
|
88
|
88
|
var u float32
|
89
|
89
|
var color color.RGBA64
|
90
|
90
|
for y := slice.Min.Y; y < slice.Max.Y; y++ {
|
91
|
|
- u = scale*(float32(y)+adjust) + offset
|
|
91
|
+ u = scale*(float32(y)+adjust) + xoffset
|
92
|
92
|
filter.SetKernelWeights(u)
|
93
|
93
|
for x := slice.Min.X; x < slice.Max.X; x++ {
|
94
|
|
- color = filter.Interpolate(u, x)
|
|
94
|
+ color = filter.Interpolate(u, x+yoffset)
|
95
|
95
|
i := output.PixOffset(x, y)
|
96
|
96
|
output.Pix[i+0] = uint8(color.R >> 8)
|
97
|
97
|
output.Pix[i+1] = uint8(color.R)
|