Skip to content

Commit e381aa7

Browse files
committed
fix: avoid using the blurring method in case it's not requested #21
1 parent e4de883 commit e381aa7

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

stackblur.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,14 +70,16 @@ func StackBlur(img *image.NRGBA, radius uint32) *image.NRGBA {
7070
pr, pg, pb, pa uint32
7171
)
7272

73+
// Stop blurring and return the original image in case the radius is less then 1.
74+
if radius < 1 {
75+
return img
76+
}
77+
7378
// Limit the maximum blur radius to 255, otherwise it overflows the multable length
7479
// and will panic with and index out of range error.
7580
if int(radius) >= len(mulTable) {
7681
radius = uint32(len(mulTable) - 1)
7782
}
78-
if radius < 1 {
79-
radius = 1
80-
}
8183

8284
div = radius + radius + 1
8385
widthMinus1 = width - 1

0 commit comments

Comments
 (0)