Skip to content

Commit

Permalink
feat: export ToNRGBA
Browse files Browse the repository at this point in the history
This function is really useful for doing your own image processing pipeline
using the tools in this package. I would need to reimplement it if it wasn't
exported.

Signed-off-by: Chris Waldon <christopher.waldon.dev@gmail.com>
  • Loading branch information
whereswaldon committed Apr 12, 2021
1 parent f687f52 commit 5280c4b
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions process.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ func (im *Image) Draw(input interface{}, output interface{}, fn func()) (image.I
ctx.Fill()

delaunay := &Delaunay{}
img := toNRGBA(src.(image.Image))
img := ToNRGBA(src.(image.Image))

blur := StackBlur(img, uint32(im.BlurRadius))
gray := Grayscale(blur)
Expand Down Expand Up @@ -246,7 +246,7 @@ func (svg *SVG) Draw(input io.Reader, output io.Writer, fn func()) (image.Image,
ctx.Fill()

delaunay := &Delaunay{}
img := toNRGBA(src)
img := ToNRGBA(src)

blur := StackBlur(img, uint32(svg.BlurRadius))
gray := Grayscale(blur)
Expand Down Expand Up @@ -305,8 +305,8 @@ func (svg *SVG) Draw(input io.Reader, output io.Writer, fn func()) (image.Image,
return nil, triangles, points, err
}

// toNRGBA converts any image type to *image.NRGBA with min-point at (0, 0).
func toNRGBA(img image.Image) *image.NRGBA {
// ToNRGBA converts any image type to *image.NRGBA with min-point at (0, 0).
func ToNRGBA(img image.Image) *image.NRGBA {
srcBounds := img.Bounds()
if srcBounds.Min.X == 0 && srcBounds.Min.Y == 0 {
if src0, ok := img.(*image.NRGBA); ok {
Expand Down

0 comments on commit 5280c4b

Please sign in to comment.