From 579058ccc08102d685db32ee819b795f15b4ab76 Mon Sep 17 00:00:00 2001 From: nfnt Date: Thu, 7 Jan 2016 20:34:21 +0100 Subject: [PATCH] Test for color-casts due to wrong alpha-channel scaling. --- resize_test.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/resize_test.go b/resize_test.go index 6f69113..2ab5145 100644 --- a/resize_test.go +++ b/resize_test.go @@ -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 ( // Use a small image size for benchmarks. We don't want memory performance // to affect the benchmark results.