diff --git a/image_test.go b/image_test.go index 35242c989..d9b71c1e3 100644 --- a/image_test.go +++ b/image_test.go @@ -1996,3 +1996,20 @@ func TestImageDrawTrianglesWithColorM(t *testing.T) { } } } + +// Issue #1137 +func TestImageDrawOver(t *testing.T) { + dst, _ := NewImage(320, 240, FilterDefault) + src := image.NewUniform(color.RGBA{0xff, 0, 0, 0xff}) + // This must not cause infinite-loop. + draw.Draw(dst, dst.Bounds(), src, image.ZP, draw.Over) + for j := 0; j < 240; j++ { + for i := 0; i < 320; i++ { + got := dst.At(i, j) + want := color.RGBA{0xff, 0, 0, 0xff} + if got != want { + t.Errorf("At(%d, %d): got: %v, want: %v", i, j, got, want) + } + } + } +} diff --git a/internal/buffered/image.go b/internal/buffered/image.go index 953c9ff62..9a9e9cde6 100644 --- a/internal/buffered/image.go +++ b/internal/buffered/image.go @@ -127,7 +127,10 @@ func (i *Image) At(x, y int) (r, g, b, a byte, err error) { if needsToDelayCommands { panic("buffered: the command queue is not available yet at At") } - // TODO: Use pending pixels + if i.pixels != nil { + idx := i.width*y + x + return i.pixels[4*idx], i.pixels[4*idx+1], i.pixels[4*idx+2], i.pixels[4*idx+3], nil + } i.resolvePendingPixels(true) return i.img.At(x, y) }