Reland(2): graphics: Appropriate rendering of edges on linear filter

This commit is contained in:
Hajime Hoshi
2017-12-11 23:07:01 +09:00
parent 362d1c417f
commit 723d153800
15 changed files with 180 additions and 86 deletions

View File

@@ -25,6 +25,7 @@ import (
"testing"
. "github.com/hajimehoshi/ebiten"
"github.com/hajimehoshi/ebiten/ebitenutil"
emath "github.com/hajimehoshi/ebiten/internal/math"
)
@@ -595,3 +596,28 @@ func BenchmarkDrawImage(b *testing.B) {
img0.DrawImage(img1, op)
}
}
func TestImageLinear(t *testing.T) {
src, _ := NewImage(32, 32, FilterLinear)
dst, _ := NewImage(64, 64, FilterNearest)
src.Fill(color.RGBA{0, 0xff, 0, 0xff})
ebitenutil.DrawRect(src, 8, 8, 16, 16, color.RGBA{0xff, 0, 0, 0xff})
op := &DrawImageOptions{}
op.GeoM.Translate(8, 8)
op.GeoM.Scale(2, 2)
r := image.Rect(8, 8, 24, 24)
op.SourceRect = &r
dst.DrawImage(src, op)
for j := 0; j < 64; j++ {
for i := 0; i < 64; i++ {
c := color.RGBAModel.Convert(dst.At(i, j)).(color.RGBA)
got := c.G
want := uint8(0)
if got != want {
t.Errorf("dst At(%d, %d).G: got %#v, want: %#v", i, j, got, want)
}
}
}
}