diff --git a/image_test.go b/image_test.go index b5b5b9ed1..7990fcd7e 100644 --- a/image_test.go +++ b/image_test.go @@ -2172,3 +2172,27 @@ func TestImageFloatTranslate(t *testing.T) { }) } } + +// Issue #1213 +func TestImageColorMCopy(t *testing.T) { + const w, h = 16, 16 + dst, _ := NewImage(w, h, FilterDefault) + src, _ := NewImage(w, h, FilterDefault) + + for k := 0; k < 256; k++ { + op := &DrawImageOptions{} + op.ColorM.Translate(float64(k)/0xff, 1, 1, 1) + op.CompositeMode = CompositeModeCopy + dst.DrawImage(src, op) + + for j := 0; j < h; j++ { + for i := 0; i < w; i++ { + got := dst.At(i, j).(color.RGBA) + want := color.RGBA{byte(k), 0xff, 0xff, 0xff} + if !sameColors(got, want, 1) { + t.Fatalf("dst.At(%d, %d), k: %d: got %v, want %v", i, j, k, got, want) + } + } + } + } +} diff --git a/internal/buffered/image.go b/internal/buffered/image.go index edf2a1f76..c1e8d2500 100644 --- a/internal/buffered/image.go +++ b/internal/buffered/image.go @@ -275,6 +275,7 @@ func (i *Image) drawImage(src *Image, bounds image.Rectangle, g mipmap.GeoM, col src.resolvePendingPixels(true) i.resolvePendingPixels(false) i.img.DrawImage(src.img, bounds, g, colorm, mode, filter) + i.invalidatePendingPixels() } // DrawTriangles draws the src image with the given vertices. @@ -329,6 +330,7 @@ func (i *Image) DrawTriangles(src *Image, vertices []float32, indices []uint16, srcImg = src.img } i.img.DrawTriangles(srcImg, vertices, indices, colorm, mode, filter, address, s, us) + i.invalidatePendingPixels() } type Shader struct {