Skip to content

Commit f0f3bd5

Browse files
Merge pull request #82 from harotobira/master
Fix rotate panic
2 parents c58fb61 + a1dcd52 commit f0f3bd5

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

transform/rotate.go

+9-3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package transform
22

33
import (
44
"image"
5+
"image/color"
56
"math"
67

78
"github.com/anthonynsimon/bild/clone"
@@ -106,9 +107,14 @@ func Rotate(img image.Image, angle float64, options *RotationOptions) *image.RGB
106107
continue
107108
}
108109

109-
srcPos := iy*src.Stride + ix*4
110-
dstPos := (y+offsetY)*dst.Stride + (x+offsetX)*4
111-
copy(dst.Pix[dstPos:dstPos+4], src.Pix[srcPos:srcPos+4])
110+
red, green, blue, alpha := src.At(ix, iy).RGBA()
111+
112+
dst.Set(x+offsetX, y+offsetY, color.RGBA64{
113+
R: uint16(red),
114+
G: uint16(green),
115+
B: uint16(blue),
116+
A: uint16(alpha),
117+
})
112118
}
113119
}
114120
})

0 commit comments

Comments
 (0)