graphics: Add TestImageScale

This commit is contained in:
Hajime Hoshi 2017-02-05 06:15:51 +09:00
parent 6d2692b0db
commit 4f45c0361d

View File

@ -207,6 +207,36 @@ func TestImageSelf(t *testing.T) {
} }
} }
func TestImageScale(t *testing.T) {
img0, _, err := openEbitenImage("testdata/ebiten.png")
if err != nil {
t.Fatal(err)
return
}
w, h := img0.Size()
img1, err := NewImage(w*2, h*2, FilterNearest)
if err != nil {
t.Fatal(err)
return
}
op := &DrawImageOptions{}
op.GeoM.Scale(2, 2)
if err := img1.DrawImage(img0, op); err != nil {
t.Fatal(err)
return
}
for j := 0; j < h*2; j++ {
for i := 0; i < w*2; i++ {
c0 := img0.At(i/2, j/2).(color.RGBA)
c1 := img1.At(i, j).(color.RGBA)
if c0 != c1 {
t.Errorf("img0.At(%[1]d, %[2]d) should equal to img1.At(%[3]d, %[4]d) but not: %[5]v vs %[6]v", i/2, j/2, i, j, c0, c1)
}
}
}
}
func TestImage90DegreeRotate(t *testing.T) { func TestImage90DegreeRotate(t *testing.T) {
img0, _, err := openEbitenImage("testdata/ebiten.png") img0, _, err := openEbitenImage("testdata/ebiten.png")
if err != nil { if err != nil {