Add test case for input data with pre-multiplied-alpha.

This commit is contained in:
nfnt 2015-05-12 15:18:07 +02:00
parent 45c239597b
commit 5a6676c19e

View File

@ -2,6 +2,7 @@ package resize
import (
"image"
"fmt"
"image/color"
"runtime"
"testing"
@ -85,6 +86,22 @@ func Test_SameSizeReturnsOriginal(t *testing.T) {
}
}
func Test_ResizeWithPremultipliedAlpha(t *testing.T) {
img := image.NewRGBA(image.Rect(0, 0, 1, 4))
for y := img.Bounds().Min.Y; y < img.Bounds().Max.Y; y++ {
// 0x80 = 0.5 * 0xFF.
img.SetRGBA(0, y, color.RGBA{0x80, 0x80, 0x80, 0x80})
}
out := Resize(1, 2, img, MitchellNetravali)
fmt.Println(out)
outputColor := out.At(0,0).(color.NRGBA)
if outputColor.R != 0xFF {
t.Fail()
}
}
const (
// Use a small image size for benchmarks. We don't want memory performance
// to affect the benchmark results.