mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-26 03:38:55 +01:00
graphicsutil: Add tests
This commit is contained in:
parent
36b249b320
commit
4c7025a05f
@ -51,6 +51,7 @@ func CopyImage(origImg image.Image) *image.RGBA {
|
|||||||
index1 := 0
|
index1 := 0
|
||||||
d0 := origImg.Stride - (x1 - x0)
|
d0 := origImg.Stride - (x1 - x0)
|
||||||
d1 := newImg.Stride - (x1-x0)*4
|
d1 := newImg.Stride - (x1-x0)*4
|
||||||
|
// Even origImg is a subimage of another image, Pix starts with 0-th index.
|
||||||
pix0 := origImg.Pix
|
pix0 := origImg.Pix
|
||||||
pix1 := newImg.Pix
|
pix1 := newImg.Pix
|
||||||
for j := 0; j < y1-y0; j++ {
|
for j := 0; j < y1-y0; j++ {
|
||||||
|
@ -89,6 +89,19 @@ func TestCopyImage(t *testing.T) {
|
|||||||
Rect: image.Rect(0, 0, 2, 2),
|
Rect: image.Rect(0, 0, 2, 2),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
In: (&image.Paletted{
|
||||||
|
Pix: []uint8{0, 64, 0, 0},
|
||||||
|
Stride: 2,
|
||||||
|
Rect: image.Rect(0, 0, 2, 2),
|
||||||
|
Palette: bigPalette,
|
||||||
|
}).SubImage(image.Rect(1, 0, 2, 1)),
|
||||||
|
Out: &image.RGBA{
|
||||||
|
Pix: []uint8{0xff, 0xff, 0xff, 0xff},
|
||||||
|
Stride: 4,
|
||||||
|
Rect: image.Rect(0, 0, 1, 1),
|
||||||
|
},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
for _, c := range cases {
|
for _, c := range cases {
|
||||||
got := CopyImage(c.In)
|
got := CopyImage(c.In)
|
||||||
|
Loading…
Reference in New Issue
Block a user