mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-10 04:57:26 +01:00
graphics: Bug fix: start pixel must start at 0 (#303)
This commit is contained in:
parent
333b0956ff
commit
3331f17723
@ -43,7 +43,7 @@ func CopyImage(origImg image.Image) *image.RGBA {
|
||||
palette[4*i+2] = rgba.B
|
||||
palette[4*i+3] = rgba.A
|
||||
}
|
||||
index0 := y0*origImg.Stride + x0
|
||||
index0 := 0
|
||||
index1 := 0
|
||||
d0 := origImg.Stride - (x1 - x0)
|
||||
d1 := newImg.Stride - (x1-x0)*4
|
||||
|
@ -24,6 +24,10 @@ import (
|
||||
)
|
||||
|
||||
func TestCopyImage(t *testing.T) {
|
||||
pal := make(color.Palette, 256)
|
||||
for i := range pal {
|
||||
pal[i] = color.White
|
||||
}
|
||||
cases := []struct {
|
||||
In image.Image
|
||||
Out *image.RGBA
|
||||
@ -43,6 +47,14 @@ func TestCopyImage(t *testing.T) {
|
||||
Rect: image.Rect(0, 0, 2, 2),
|
||||
},
|
||||
},
|
||||
{
|
||||
In: image.NewPaletted(image.Rect(0, 0, 240, 160), pal).SubImage(image.Rect(238, 158, 240, 160)),
|
||||
Out: &image.RGBA{
|
||||
Pix: []uint8{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff},
|
||||
Stride: 8,
|
||||
Rect: image.Rect(0, 0, 2, 2),
|
||||
},
|
||||
},
|
||||
{
|
||||
In: &image.RGBA{
|
||||
Pix: []uint8{0, 0, 0, 0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0, 0, 0, 0},
|
||||
|
Loading…
Reference in New Issue
Block a user