Crate stackblur[][src]

Expand description

Fast gaussian blur approximation.

A Rust implementation of StackBlur by Mario Klingemann. Very fast and accurate gaussian blur approximation. Based off of Java implementation by Enrique López Mañas, licensed under Apache 2.0.

Examples

use std::num::{NonZeroU8, NonZeroUsize};

use stackblur::blur;

const RED: u32 = 0xffff0000;
const GREEN: u32 = 0xff00ff00;
const BLUE: u32 = 0xff0000ff;

// load your image, u32 RGBA pixels
let mut pixels: Vec<u32> = vec![
    RED, GREEN, GREEN, RED,
    GREEN, RED, BLUE, GREEN,
    GREEN, BLUE, RED, GREEN,
    RED, GREEN, GREEN, RED,
];

// blur!
blur(
    &mut pixels,
    NonZeroUsize::new(4).unwrap(),
    NonZeroUsize::new(4).unwrap(),
    NonZeroU8::new(1).unwrap(),
);

Functions

blur

Performs a pass of stackblur in both directions. Input is expected to be in linear RGB color space.

blur_horiz

Performs a horizontal pass of stackblur. Input is expected to be in linear RGB color space.

blur_vert

Performs a vertical pass of stackblur. Input is expected to be in linear RGB color space.