Skip to content

Commit

Permalink
fix: avoid using the blurring method in case it's not requested #21
Browse files Browse the repository at this point in the history
  • Loading branch information
esimov committed Apr 1, 2022
1 parent e4de883 commit e381aa7
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions stackblur.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,16 @@ func StackBlur(img *image.NRGBA, radius uint32) *image.NRGBA {
pr, pg, pb, pa uint32
)

// Stop blurring and return the original image in case the radius is less then 1.
if radius < 1 {
return img
}

// Limit the maximum blur radius to 255, otherwise it overflows the multable length
// and will panic with and index out of range error.
if int(radius) >= len(mulTable) {
radius = uint32(len(mulTable) - 1)
}
if radius < 1 {
radius = 1
}

div = radius + radius + 1
widthMinus1 = width - 1
Expand Down

0 comments on commit e381aa7

Please sign in to comment.