Add test case for input data with pre-multiplied-alpha.
This commit is contained in:
parent
45c239597b
commit
5a6676c19e
|
@ -2,6 +2,7 @@ package resize
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"image"
|
"image"
|
||||||
|
"fmt"
|
||||||
"image/color"
|
"image/color"
|
||||||
"runtime"
|
"runtime"
|
||||||
"testing"
|
"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 (
|
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.
|
||||||
|
|
Loading…
Reference in New Issue
Block a user