mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-10 04:57:26 +01:00
graphics: Add TestImageMipmapNegativeDet
This commit is contained in:
parent
7b91f3025c
commit
db1030a6d4
@ -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
|
// Issue #710
|
||||||
func TestImageMipmapColor(t *testing.T) {
|
func TestImageMipmapColor(t *testing.T) {
|
||||||
img0, _ := NewImage(256, 256, FilterDefault)
|
img0, _ := NewImage(256, 256, FilterDefault)
|
||||||
|
Loading…
Reference in New Issue
Block a user