From d91a467c53923a25c69e23f96aca5c5e31d3fd2d Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Sat, 17 Jan 2015 16:41:03 +0900 Subject: [PATCH] Add TestImageDotByDotInversion --- image_test.go | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/image_test.go b/image_test.go index 6beb5f2b2..e81cc0f08 100644 --- a/image_test.go +++ b/image_test.go @@ -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)