mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-10 04:57:26 +01:00
restorable: Bug fix: PutQuadVertices should take the source image
Fixes #898
This commit is contained in:
parent
aee26eec1e
commit
a7e7e007ca
@ -1653,7 +1653,7 @@ func TestImageSubImageSubImage(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// Issue 839
|
||||
// Issue #839
|
||||
func TestImageTooSmallMipmap(t *testing.T) {
|
||||
const w, h = 16, 16
|
||||
src, _ := NewImage(w, h, FilterDefault)
|
||||
@ -1680,3 +1680,37 @@ func TestImageZeroSizedMipmap(t *testing.T) {
|
||||
op.Filter = FilterLinear
|
||||
dst.DrawImage(src.SubImage(image.ZR).(*Image), op)
|
||||
}
|
||||
|
||||
// Issue #898
|
||||
func TestImageFillingAndEdges(t *testing.T) {
|
||||
const (
|
||||
srcw, srch = 16, 16
|
||||
dstw, dsth = 256, 16
|
||||
)
|
||||
|
||||
println("-- start --")
|
||||
defer println("-- end --")
|
||||
src, _ := NewImage(srcw, srch, FilterDefault)
|
||||
dst, _ := NewImage(dstw, dsth, FilterDefault)
|
||||
|
||||
src.Fill(color.White)
|
||||
dst.Fill(color.Black)
|
||||
|
||||
op := &DrawImageOptions{}
|
||||
op.GeoM.Scale(float64(dstw-2)/float64(srcw), float64(dsth-2)/float64(srch))
|
||||
op.GeoM.Translate(1, 1)
|
||||
dst.DrawImage(src, op)
|
||||
|
||||
for j := 0; j < dsth; j++ {
|
||||
for i := 0; i < dstw; i++ {
|
||||
got := dst.At(i, j).(color.RGBA)
|
||||
want := color.RGBA{0xff, 0xff, 0xff, 0xff}
|
||||
if i == 0 || i == dstw-1 || j == 0 || j == dsth-1 {
|
||||
want = color.RGBA{0, 0, 0, 0xff}
|
||||
}
|
||||
if got != want {
|
||||
t.Errorf("dst.At(%d, %d): got: %v, want: %v", i, j, got, want)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -215,7 +215,7 @@ func (i *Image) fill(r, g, b, a uint8) {
|
||||
dw, dh := i.internalSize()
|
||||
sw, sh := emptyImage.Size()
|
||||
vs := make([]float32, 4*graphics.VertexFloatNum)
|
||||
graphics.PutQuadVertices(vs, i, 0, 0, sw, sh,
|
||||
graphics.PutQuadVertices(vs, emptyImage, 0, 0, sw, sh,
|
||||
float32(dw)/float32(sw), 0, 0, float32(dh)/float32(sh), 0, 0,
|
||||
rf, gf, bf, af)
|
||||
is := graphics.QuadIndices()
|
||||
|
Loading…
Reference in New Issue
Block a user