Skip to content

Commit

Permalink
Merge pull request #82 from harotobira/master
Browse files Browse the repository at this point in the history
Fix rotate panic
  • Loading branch information
anthonynsimon committed May 3, 2020
2 parents c58fb61 + a1dcd52 commit f0f3bd5
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions transform/rotate.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package transform

import (
"image"
"image/color"
"math"

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

srcPos := iy*src.Stride + ix*4
dstPos := (y+offsetY)*dst.Stride + (x+offsetX)*4
copy(dst.Pix[dstPos:dstPos+4], src.Pix[srcPos:srcPos+4])
red, green, blue, alpha := src.At(ix, iy).RGBA()

dst.Set(x+offsetX, y+offsetY, color.RGBA64{
R: uint16(red),
G: uint16(green),
B: uint16(blue),
A: uint16(alpha),
})
}
}
})
Expand Down

0 comments on commit f0f3bd5

Please sign in to comment.