graphics: Fix TestImage4096

This commit is contained in:
Hajime Hoshi 2018-02-03 15:39:17 +09:00
parent fe140c2caf
commit 2014822f12

View File

@ -685,24 +685,38 @@ func TestImage4096(t *testing.T) {
src, _ := NewImage(4096, 4096, FilterNearest) src, _ := NewImage(4096, 4096, FilterNearest)
dst, _ := NewImage(4096, 4096, FilterNearest) dst, _ := NewImage(4096, 4096, FilterNearest)
pix := make([]byte, 4096*4096*4) pix := make([]byte, 4096*4096*4)
for j := 4095; j < 4096; j++ { for i := 0; i < 4096; i++ {
for i := 4095; i < 4096; i++ { j := 4095
idx := 4 * (i + j*4096) idx := 4 * (i + j*4096)
pix[idx] = uint8(i + j) pix[idx] = uint8(i + j)
pix[idx+1] = uint8((i + j) >> 8) pix[idx+1] = uint8((i + j) >> 8)
pix[idx+2] = uint8((i + j) >> 16) pix[idx+2] = uint8((i + j) >> 16)
pix[idx+3] = 0xff pix[idx+3] = 0xff
} }
for j := 0; j < 4096; j++ {
i := 4095
idx := 4 * (i + j*4096)
pix[idx] = uint8(i + j)
pix[idx+1] = uint8((i + j) >> 8)
pix[idx+2] = uint8((i + j) >> 16)
pix[idx+3] = 0xff
} }
src.ReplacePixels(pix) src.ReplacePixels(pix)
dst.DrawImage(src, nil) dst.DrawImage(src, nil)
for i := 4095; i < 4096; i++ {
j := 4095
got := color.RGBAModel.Convert(dst.At(i, j)).(color.RGBA)
want := color.RGBA{uint8(i + j), uint8((i + j) >> 8), uint8((i + j) >> 16), 0xff}
if got != want {
t.Errorf("At(%d, %d): got: %#v, want: %#v", i, j, got, want)
}
}
for j := 4095; j < 4096; j++ { for j := 4095; j < 4096; j++ {
for i := 4095; i < 4096; i++ { i := 4095
got := color.RGBAModel.Convert(dst.At(i, j)).(color.RGBA) got := color.RGBAModel.Convert(dst.At(i, j)).(color.RGBA)
want := color.RGBA{uint8(i + j), uint8((i + j) >> 8), uint8((i + j) >> 16), 0xff} want := color.RGBA{uint8(i + j), uint8((i + j) >> 8), uint8((i + j) >> 16), 0xff}
if got != want { if got != want {
t.Errorf("At(%d, %d): got: %#v, want: %#v", i, j, got, want) t.Errorf("At(%d, %d): got: %#v, want: %#v", i, j, got, want)
}
} }
} }
} }