Skip to content

Commit

Permalink
Merge pull request #1362 from Mike-Neto/master
Browse files Browse the repository at this point in the history
Fixes #983. blur 0.0 panic
  • Loading branch information
HeroicKatora committed Nov 16, 2020
2 parents 085300e + cd4c57a commit 28ac73e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
8 changes: 8 additions & 0 deletions src/imageops/mod.rs
Expand Up @@ -286,6 +286,7 @@ where
mod tests {

use super::overlay;
use crate::RgbaImage;
use crate::ImageBuffer;
use crate::color::Rgb;

Expand Down Expand Up @@ -366,4 +367,11 @@ mod tests {
assert_eq!(img.get_pixel(0, 0), &start);
assert_eq!(img.get_pixel(0, img.height() - 1), &end);
}

#[test]
/// Test blur doens't panick when passed 0.0
fn test_blur_zero() {
let image = RgbaImage::new(50, 50);
let _ = super::blur(&image, 0.0);
}
}
2 changes: 1 addition & 1 deletion src/imageops/sample.rs
Expand Up @@ -755,7 +755,7 @@ pub fn blur<I: GenericImageView>(
where
I::Pixel: 'static,
{
let sigma = if sigma < 0.0 { 1.0 } else { sigma };
let sigma = if sigma <= 0.0 { 1.0 } else { sigma };

let mut method = Filter {
kernel: Box::new(|x| gaussian(x, sigma)),
Expand Down

0 comments on commit 28ac73e

Please sign in to comment.