Add TestImageDotByDotInversion

This commit is contained in:
Hajime Hoshi 2015-01-17 16:41:03 +09:00
parent 7835f5cb2e
commit d91a467c53

View File

@ -19,6 +19,7 @@ import (
"image"
"image/color"
_ "image/png"
"math"
"testing"
)
@ -145,4 +146,32 @@ func TestImageSelf(t *testing.T) {
}
}
func TestImageDotByDotInversion(t *testing.T) {
img0, _, err := openImage("testdata/ebiten.png")
if err != nil {
t.Fatal(err)
return
}
w, h := img0.Size()
img1, err := NewImage(w, h, FilterNearest)
if err != nil {
t.Fatal(err)
return
}
op := &DrawImageOptions{}
op.GeoM.Rotate(2 * math.Pi / 2)
op.GeoM.Translate(float64(w), float64(h))
img1.DrawImage(img0, op)
for j := 0; j < h; j++ {
for i := 0; i < w; i++ {
c0 := img0.At(i, j).(color.RGBA)
c1 := img1.At(w-i-1, h-j-1).(color.RGBA)
if c0 != c1 {
t.Errorf("c0 should equal to c1 but not: c0: %v, c1: %v", c0, c1)
}
}
}
}
// TODO: Add more tests (e.g. DrawImage with color matrix)