diff --git a/resize_test.go b/resize_test.go index 3ba03f2..487a69d 100644 --- a/resize_test.go +++ b/resize_test.go @@ -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.