op/paint: fix subimage rendering by ImageOp

This change is a follow-up to bcf3ff77ff, fixing the two renderers to
properly render images with non-zero origins.

Signed-off-by: Pierre Curto <pierre.curto@gmail.com>
This commit is contained in:
Pierre Curto
2021-11-10 22:18:59 +01:00
committed by Elias Naur
parent 86c4947ccd
commit 9d05f35341
4 changed files with 13 additions and 11 deletions
Binary file not shown.

Before

Width:  |  Height:  |  Size: 394 B

After

Width:  |  Height:  |  Size: 395 B

+8 -8
View File
@@ -339,10 +339,10 @@ func TestImageRGBA(t *testing.T) {
w := newWindow(t, 10, 10)
im := image.NewRGBA(image.Rect(0, 0, 5, 5))
im.Set(3, 3, colornames.Black)
im.Set(4, 3, colornames.Black)
im.Set(3, 4, colornames.Black)
im.Set(4, 4, colornames.Black)
im.Set(3, 3, colornames.Red)
im.Set(4, 3, colornames.Red)
im.Set(3, 4, colornames.Red)
im.Set(4, 4, colornames.Red)
im = im.SubImage(image.Rect(2, 2, 5, 5)).(*image.RGBA)
paint.NewImageOp(im).Add(o)
paint.PaintOp{}.Add(o)
@@ -350,10 +350,10 @@ func TestImageRGBA(t *testing.T) {
t.Error(err)
}
}, func(r result) {
r.expect(1, 1, colornames.Black)
r.expect(2, 1, colornames.Black)
r.expect(1, 2, colornames.Black)
r.expect(2, 2, colornames.Black)
r.expect(1, 1, colornames.Red)
r.expect(2, 1, colornames.Red)
r.expect(1, 2, colornames.Red)
r.expect(2, 2, colornames.Red)
})
}