diff --git a/examples/scaledown/scaledown-test-cmr.png b/examples/scaledown/scaledown-test-cmr.png new file mode 100644 index 0000000000..c0087e2aea Binary files /dev/null and b/examples/scaledown/scaledown-test-cmr.png differ diff --git a/examples/scaledown/scaledown-test-gauss.png b/examples/scaledown/scaledown-test-gauss.png new file mode 100644 index 0000000000..ce26b3c748 Binary files /dev/null and b/examples/scaledown/scaledown-test-gauss.png differ diff --git a/examples/scaledown/scaledown-test-lcz2.png b/examples/scaledown/scaledown-test-lcz2.png new file mode 100644 index 0000000000..f01d582062 Binary files /dev/null and b/examples/scaledown/scaledown-test-lcz2.png differ diff --git a/examples/scaledown/scaledown-test-near.png b/examples/scaledown/scaledown-test-near.png new file mode 100644 index 0000000000..ad21124f84 Binary files /dev/null and b/examples/scaledown/scaledown-test-near.png differ diff --git a/examples/scaledown/scaledown-test-tri.png b/examples/scaledown/scaledown-test-tri.png new file mode 100644 index 0000000000..5bd92f5c49 Binary files /dev/null and b/examples/scaledown/scaledown-test-tri.png differ diff --git a/src/imageops/sample.rs b/src/imageops/sample.rs index 1293a5e5e8..a5f49198de 100644 --- a/src/imageops/sample.rs +++ b/src/imageops/sample.rs @@ -12,7 +12,72 @@ use image::GenericImageView; use math::utils::clamp; use traits::{Enlargeable, Primitive}; -/// Available Sampling Filters +/// Available Sampling Filters. +/// +/// ## Examples +/// +/// To test the different sampling filters on a real example, you can find two +/// examples called +/// [`scaledown`](https://github.com/image-rs/image/tree/master/examples/scaledown) +/// and +/// [`scaleup`](https://github.com/image-rs/image/tree/master/examples/scaleup) +/// in the `examples` directory of the crate source code. +/// +/// Here is a 3.58 MiB +/// [test image](https://github.com/image-rs/image/blob/master/examples/scaledown/test.jpg) +/// that has been scaled down to 300x225 px: +/// +/// +///
+///
+///
+/// Nearest Neighbor +///
+///
+///
+/// Linear: Triangle +///
+///
+///
+/// Cubic: Catmull-Rom +///
+///
+///
+/// Gaussian +///
+///
+///
+/// Lanczos with window 3 +///
+///
+/// +/// ## Speed +/// +/// Time required to create each of the examples above, tested on an Intel +/// i7-4770 CPU with Rust 1.37 in release mode: +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +///
Nearest31 ms
Triangle414 ms
CatmullRom817 ms
Gaussian1180 ms
Lanczos31170 ms
#[derive(Clone, Copy, Debug)] pub enum FilterType { /// Nearest Neighbor