graphics: Add TestImageMipmapNegativeDet

This commit is contained in:
Hajime Hoshi 2019-07-30 14:10:37 +09:00
parent 7b91f3025c
commit db1030a6d4

View File

@ -1047,6 +1047,60 @@ func TestImageMipmap(t *testing.T) {
}
}
func TestImageMipmapNegativeDet(t *testing.T) {
src, _, err := openEbitenImage()
if err != nil {
t.Fatal(err)
return
}
w, h := src.Size()
l1, _ := NewImage(w/2, h/2, FilterDefault)
op := &DrawImageOptions{}
op.GeoM.Scale(1/2.0, 1/2.0)
op.Filter = FilterLinear
l1.DrawImage(src, op)
l1w, l1h := l1.Size()
l2, _ := NewImage(l1w/2, l1h/2, FilterDefault)
op = &DrawImageOptions{}
op.GeoM.Scale(1/2.0, 1/2.0)
op.Filter = FilterLinear
l2.DrawImage(l1, op)
gotDst, _ := NewImage(w, h, FilterDefault)
op = &DrawImageOptions{}
op.GeoM.Scale(-1/5.0, -1/5.0)
op.GeoM.Translate(float64(w), float64(h))
op.Filter = FilterLinear
gotDst.DrawImage(src, op)
wantDst, _ := NewImage(w, h, FilterDefault)
op = &DrawImageOptions{}
op.GeoM.Scale(-4.0/5.0, -4.0/5.0)
op.GeoM.Translate(float64(w), float64(h))
op.Filter = FilterLinear
wantDst.DrawImage(l2, op)
allZero := true
for j := 0; j < h; j++ {
for i := 0; i < h; i++ {
got := gotDst.At(i, j).(color.RGBA)
want := wantDst.At(i, j).(color.RGBA)
if !sameColors(got, want, 1) {
t.Errorf("At(%d, %d): got: %#v, want: %#v", i, j, got, want)
}
if got.A > 0 {
allZero = false
}
}
}
if allZero {
t.Errorf("the image must include non-zero values but not")
}
}
// Issue #710
func TestImageMipmapColor(t *testing.T) {
img0, _ := NewImage(256, 256, FilterDefault)