mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-10-19 22:34:49 +08:00
Reland(2): graphics: Appropriate rendering of edges on linear filter
This commit is contained in:
@@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user