Test for color-casts due to wrong alpha-channel scaling.

This commit is contained in:
nfnt 2016-01-07 20:34:21 +01:00
parent dc93e1b98c
commit 579058ccc0

View File

@ -210,6 +210,22 @@ func Test_ResizeWithPremultipliedAlpha(t *testing.T) {
} }
} }
func Test_ResizeWithTranslucentColor(t *testing.T) {
img := image.NewNRGBA(image.Rect(0, 0, 1, 2))
// Set the pixel colors to an "invisible green" and white.
// After resizing, the green shouldn't be visible.
img.SetNRGBA(0, 0, color.NRGBA{0x00, 0xFF, 0x00, 0x00})
img.SetNRGBA(0, 1, color.NRGBA{0x00, 0x00, 0x00, 0xFF})
out := Resize(1, 1, img, Bilinear)
_, g, _, _ := out.At(0, 0).RGBA()
if g != 0x00 {
t.Errorf("%+v", g)
}
}
const ( const (
// Use a small image size for benchmarks. We don't want memory performance // Use a small image size for benchmarks. We don't want memory performance
// to affect the benchmark results. // to affect the benchmark results.