|
|
@@ -132,6 +132,36 @@ func Resize(width, height uint, img image.Image, interp InterpolationFunction) i
|
|
|
}
|
|
|
wg.Wait()
|
|
|
return result
|
|
|
+ case *image.NRGBA:
|
|
|
+ // 8-bit precision
|
|
|
+ temp := image.NewNRGBA(image.Rect(0, 0, input.Bounds().Dy(), int(width)))
|
|
|
+ result := image.NewNRGBA(image.Rect(0, 0, int(width), int(height)))
|
|
|
+
|
|
|
+ // horizontal filter, results in transposed temporary image
|
|
|
+ coeffs, offset, filterLength := createWeights8(temp.Bounds().Dy(), taps, blur, scaleX, kernel)
|
|
|
+ wg.Add(cpus)
|
|
|
+ for i := 0; i < cpus; i++ {
|
|
|
+ slice := makeSlice(temp, i, cpus).(*image.NRGBA)
|
|
|
+ go func() {
|
|
|
+ defer wg.Done()
|
|
|
+ resizeNRGBA(input, slice, scaleX, coeffs, offset, filterLength)
|
|
|
+ }()
|
|
|
+ }
|
|
|
+ wg.Wait()
|
|
|
+
|
|
|
+ // horizontal filter on transposed image, result is not transposed
|
|
|
+ coeffs, offset, filterLength = createWeights8(result.Bounds().Dy(), taps, blur, scaleY, kernel)
|
|
|
+ wg.Add(cpus)
|
|
|
+ for i := 0; i < cpus; i++ {
|
|
|
+ slice := makeSlice(result, i, cpus).(*image.NRGBA)
|
|
|
+ go func() {
|
|
|
+ defer wg.Done()
|
|
|
+ resizeNRGBA(temp, slice, scaleY, coeffs, offset, filterLength)
|
|
|
+ }()
|
|
|
+ }
|
|
|
+ wg.Wait()
|
|
|
+ return result
|
|
|
+
|
|
|
case *image.YCbCr:
|
|
|
// 8-bit precision
|
|
|
// accessing the YCbCr arrays in a tight loop is slow.
|
|
|
@@ -179,6 +209,35 @@ func Resize(width, height uint, img image.Image, interp InterpolationFunction) i
|
|
|
}
|
|
|
wg.Wait()
|
|
|
|
|
|
+ // horizontal filter on transposed image, result is not transposed
|
|
|
+ coeffs, offset, filterLength = createWeights16(result.Bounds().Dy(), taps, blur, scaleY, kernel)
|
|
|
+ wg.Add(cpus)
|
|
|
+ for i := 0; i < cpus; i++ {
|
|
|
+ slice := makeSlice(result, i, cpus).(*image.NRGBA64)
|
|
|
+ go func() {
|
|
|
+ defer wg.Done()
|
|
|
+ resizeNRGBA64(temp, slice, scaleY, coeffs, offset, filterLength)
|
|
|
+ }()
|
|
|
+ }
|
|
|
+ wg.Wait()
|
|
|
+ return result
|
|
|
+ case *image.NRGBA64:
|
|
|
+ // 16-bit precision
|
|
|
+ temp := image.NewNRGBA64(image.Rect(0, 0, input.Bounds().Dy(), int(width)))
|
|
|
+ result := image.NewNRGBA64(image.Rect(0, 0, int(width), int(height)))
|
|
|
+
|
|
|
+ // horizontal filter, results in transposed temporary image
|
|
|
+ coeffs, offset, filterLength := createWeights16(temp.Bounds().Dy(), taps, blur, scaleX, kernel)
|
|
|
+ wg.Add(cpus)
|
|
|
+ for i := 0; i < cpus; i++ {
|
|
|
+ slice := makeSlice(temp, i, cpus).(*image.NRGBA64)
|
|
|
+ go func() {
|
|
|
+ defer wg.Done()
|
|
|
+ resizeNRGBA64(input, slice, scaleX, coeffs, offset, filterLength)
|
|
|
+ }()
|
|
|
+ }
|
|
|
+ wg.Wait()
|
|
|
+
|
|
|
// horizontal filter on transposed image, result is not transposed
|
|
|
coeffs, offset, filterLength = createWeights16(result.Bounds().Dy(), taps, blur, scaleY, kernel)
|
|
|
wg.Add(cpus)
|