fix issue 23

This commit is contained in:
Laurent Le Goff 2012-04-24 10:28:31 +02:00
parent 041bb7cbbb
commit fda5c8e713

View file

@ -116,33 +116,35 @@ func DrawImage(src image.Image, dest draw.Image, tr MatrixTransform, op draw.Op,
u = x u = x
v = y v = y
tr.InverseTransform(&u, &v) tr.InverseTransform(&u, &v)
c1 = dest.At(int(x), int(y)) if bounds.Min.X <= int(u) && bounds.Max.X > int(u) && bounds.Min.Y <= int(v) && bounds.Max.Y > int(v) {
switch filter { c1 = dest.At(int(x), int(y))
case LinearFilter: switch filter {
c2 = src.At(int(u), int(v)) case LinearFilter:
case BilinearFilter: c2 = src.At(int(u), int(v))
c2 = getColorBilinear(src, u, v) case BilinearFilter:
case BicubicFilter: c2 = getColorBilinear(src, u, v)
c2 = getColorBicubic(src, u, v) case BicubicFilter:
c2 = getColorBicubic(src, u, v)
}
switch op {
case draw.Over:
r1, g1, b1, a1 = c1.RGBA()
r2, g2, b2, a2 = c2.RGBA()
ia = M - a2
r = ((r1 * ia) / M) + r2
g = ((g1 * ia) / M) + g2
b = ((b1 * ia) / M) + b2
a = ((a1 * ia) / M) + a2
color.R = uint8(r >> 8)
color.G = uint8(g >> 8)
color.B = uint8(b >> 8)
color.A = uint8(a >> 8)
cr = color
default:
cr = c2
}
dest.Set(int(x), int(y), cr)
} }
switch op {
case draw.Over:
r1, g1, b1, a1 = c1.RGBA()
r2, g2, b2, a2 = c2.RGBA()
ia = M - a2
r = ((r1 * ia) / M) + r2
g = ((g1 * ia) / M) + g2
b = ((b1 * ia) / M) + b2
a = ((a1 * ia) / M) + a2
color.R = uint8(r >> 8)
color.G = uint8(g >> 8)
color.B = uint8(b >> 8)
color.A = uint8(a >> 8)
cr = color
default:
cr = c2
}
dest.Set(int(x), int(y), cr)
} }
} }
} }