]> Cypherpunks repositories - gostls13.git/commitdiff
exp/draw: fix double-counting of pt.Min for the src and mask points.
authorNigel Tao <nigeltao@golang.org>
Fri, 10 Sep 2010 09:48:27 +0000 (19:48 +1000)
committerNigel Tao <nigeltao@golang.org>
Fri, 10 Sep 2010 09:48:27 +0000 (19:48 +1000)
The min is typically zero, which is why this hasn't bitten us yet.

R=r
CC=golang-dev
https://golang.org/cl/2119048

src/pkg/exp/draw/draw.go

index 00bd829467bfaf8c45892c3960b2300d9432cfca..d76f7aa550681cc3db30fddee97d0a0ae3dd33d9 100644 (file)
@@ -44,14 +44,14 @@ func Draw(dst Image, r image.Rectangle, src image.Image, sp image.Point) {
 // TODO(nigeltao): Optimize this.
 func DrawMask(dst Image, r image.Rectangle, src image.Image, sp image.Point, mask image.Image, mp image.Point, op Op) {
        sb := src.Bounds()
-       dx, dy := sb.Dx()-sp.X, sb.Dy()-sp.Y
+       dx, dy := sb.Max.X-sp.X, sb.Max.Y-sp.Y
        if mask != nil {
                mb := mask.Bounds()
-               if dx > mb.Dx()-mp.X {
-                       dx = mb.Dx() - mp.X
+               if dx > mb.Max.X-mp.X {
+                       dx = mb.Max.X - mp.X
                }
-               if dy > mb.Dy()-mp.Y {
-                       dy = mb.Dy() - mp.Y
+               if dy > mb.Max.Y-mp.Y {
+                       dy = mb.Max.Y - mp.Y
                }
        }
        if r.Dx() > dx {