This commit is contained in:
Laurent Le Goff 2011-04-14 15:03:17 +02:00
parent d84ea36159
commit 45159ffd27
2 changed files with 144 additions and 136 deletions

View file

@ -56,10 +56,14 @@ func getColorCubicRow(img image.Image, x, y, offset float64) image.Color {
c1 := img.At(int(x+1), int(y)) c1 := img.At(int(x+1), int(y))
c2 := img.At(int(x+2), int(y)) c2 := img.At(int(x+2), int(y))
c3 := img.At(int(x+3), int(y)) c3 := img.At(int(x+3), int(y))
rt, gt, bt, at := c0.RGBA(); r0, g0, b0, a0 := float64(rt), float64(gt), float64(bt), float64(at) rt, gt, bt, at := c0.RGBA()
rt, gt, bt, at = c1.RGBA(); r1, g1, b1, a1 := float64(rt), float64(gt), float64(bt), float64(at) r0, g0, b0, a0 := float64(rt), float64(gt), float64(bt), float64(at)
rt, gt, bt, at = c2.RGBA(); r2, g2, b2, a2 := float64(rt), float64(gt), float64(bt), float64(at) rt, gt, bt, at = c1.RGBA()
rt, gt, bt, at = c3.RGBA(); r3, g3, b3, a3 := float64(rt), float64(gt), float64(bt), float64(at) r1, g1, b1, a1 := float64(rt), float64(gt), float64(bt), float64(at)
rt, gt, bt, at = c2.RGBA()
r2, g2, b2, a2 := float64(rt), float64(gt), float64(bt), float64(at)
rt, gt, bt, at = c3.RGBA()
r3, g3, b3, a3 := float64(rt), float64(gt), float64(bt), float64(at)
r, g, b, a := cubic(offset, r0, r1, r2, r3), cubic(offset, g0, g1, g2, g3), cubic(offset, b0, b1, b2, b3), cubic(offset, a0, a1, a2, a3) r, g, b, a := cubic(offset, r0, r1, r2, r3), cubic(offset, g0, g1, g2, g3), cubic(offset, b0, b1, b2, b3), cubic(offset, a0, a1, a2, a3)
return image.RGBAColor{uint8(r >> 8), uint8(g >> 8), uint8(b >> 8), uint8(a >> 8)} return image.RGBAColor{uint8(r >> 8), uint8(g >> 8), uint8(b >> 8), uint8(a >> 8)}
} }
@ -73,10 +77,14 @@ func getColorBicubic(img image.Image, x, y float64) image.Color {
c1 := getColorCubicRow(img, x0-1, y0, dx) c1 := getColorCubicRow(img, x0-1, y0, dx)
c2 := getColorCubicRow(img, x0-1, y0+1, dx) c2 := getColorCubicRow(img, x0-1, y0+1, dx)
c3 := getColorCubicRow(img, x0-1, y0+2, dx) c3 := getColorCubicRow(img, x0-1, y0+2, dx)
rt, gt, bt, at := c0.RGBA(); r0, g0, b0, a0 := float64(rt), float64(gt), float64(bt), float64(at) rt, gt, bt, at := c0.RGBA()
rt, gt, bt, at = c1.RGBA(); r1, g1, b1, a1 := float64(rt), float64(gt), float64(bt), float64(at) r0, g0, b0, a0 := float64(rt), float64(gt), float64(bt), float64(at)
rt, gt, bt, at = c2.RGBA(); r2, g2, b2, a2 := float64(rt), float64(gt), float64(bt), float64(at) rt, gt, bt, at = c1.RGBA()
rt, gt, bt, at = c3.RGBA(); r3, g3, b3, a3 := float64(rt), float64(gt), float64(bt), float64(at) r1, g1, b1, a1 := float64(rt), float64(gt), float64(bt), float64(at)
rt, gt, bt, at = c2.RGBA()
r2, g2, b2, a2 := float64(rt), float64(gt), float64(bt), float64(at)
rt, gt, bt, at = c3.RGBA()
r3, g3, b3, a3 := float64(rt), float64(gt), float64(bt), float64(at)
r, g, b, a := cubic(dy, r0, r1, r2, r3), cubic(dy, g0, g1, g2, g3), cubic(dy, b0, b1, b2, b3), cubic(dy, a0, a1, a2, a3) r, g, b, a := cubic(dy, r0, r1, r2, r3), cubic(dy, g0, g1, g2, g3), cubic(dy, b0, b1, b2, b3), cubic(dy, a0, a1, a2, a3)
return image.RGBAColor{uint8(r >> 8), uint8(g >> 8), uint8(b >> 8), uint8(a >> 8)} return image.RGBAColor{uint8(r >> 8), uint8(g >> 8), uint8(b >> 8), uint8(a >> 8)}
} }

View file

@ -26,7 +26,7 @@ func (tr MatrixTransform) Transform(points ...*float64) {
} }
} }
func (tr MatrixTransform) TransformRectangle(x0, y0, x2, y2*float64) { func (tr MatrixTransform) TransformRectangle(x0, y0, x2, y2 *float64) {
x1 := *x2 x1 := *x2
y1 := *y0 y1 := *y0
x3 := *x0 x3 := *x0
@ -144,10 +144,10 @@ func (tr1 MatrixTransform) Multiply(tr2 MatrixTransform) MatrixTransform {
func (tr *MatrixTransform) Scale(sx, sy float64) *MatrixTransform { func (tr *MatrixTransform) Scale(sx, sy float64) *MatrixTransform {
tr[0] = sx*tr[0] tr[0] = sx * tr[0]
tr[1] = sx*tr[1] tr[1] = sx * tr[1]
tr[2] = sy*tr[2] tr[2] = sy * tr[2]
tr[3] = sy*tr[3] tr[3] = sy * tr[3]
return tr return tr
} }