diff --git a/Cargo.toml b/Cargo.toml index b922ce7..6d51c6b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,7 +8,8 @@ authors = [ "TyOverby ", "HeroicKatora", "Calum", - "CensoredUsername "] + "CensoredUsername ", + "Robzz"] [dependencies] byteorder = "1.2.*" diff --git a/tests/decode_images.rs b/tests/decode_images.rs new file mode 100644 index 0000000..4da271a --- /dev/null +++ b/tests/decode_images.rs @@ -0,0 +1,57 @@ +extern crate tiff; + +use tiff::ColorType; +use tiff::decoder::{Decoder, DecodingResult}; + +use std::fs::File; + +#[test] +fn test_gray_u8() +{ + let img_file = File::open("./tests/images/minisblack-1c-8b.tiff").expect("Cannot find test image!"); + let mut decoder = Decoder::new(img_file).expect("Cannot create decoder"); + assert_eq!(decoder.colortype().unwrap(), ColorType::Gray(8)); + let img_res = decoder.read_image(); + assert!(img_res.is_ok()); +} + +#[test] +fn test_rgb_u8() +{ + let img_file = File::open("./tests/images/rgb-3c-8b.tiff").expect("Cannot find test image!"); + let mut decoder = Decoder::new(img_file).expect("Cannot create decoder"); + assert_eq!(decoder.colortype().unwrap(), ColorType::RGB(8)); + let img_res = decoder.read_image(); + assert!(img_res.is_ok()); +} + +#[test] +fn test_gray_u16() +{ + let img_file = File::open("./tests/images/minisblack-1c-16b.tiff").expect("Cannot find test image!"); + let mut decoder = Decoder::new(img_file).expect("Cannot create decoder"); + assert_eq!(decoder.colortype().unwrap(), ColorType::Gray(16)); + let img_res = decoder.read_image(); + assert!(img_res.is_ok()); +} + +#[test] +fn test_rgb_u16() +{ + let img_file = File::open("./tests/images/rgb-3c-16b.tiff").expect("Cannot find test image!"); + let mut decoder = Decoder::new(img_file).expect("Cannot create decoder"); + assert_eq!(decoder.colortype().unwrap(), ColorType::RGB(16)); + let img_res = decoder.read_image(); + assert!(img_res.is_ok()); +} + +// TODO: GrayA support +//#[test] +//fn test_gray_alpha_u8() +//{ + //let img_file = File::open("./tests/images/minisblack-2c-8b-alpha.tiff").expect("Cannot find test image!"); + //let mut decoder = Decoder::new(img_file).expect("Cannot create decoder"); + //assert_eq!(decoder.colortype().unwrap(), ColorType::GrayA(8)); + //let img_res = decoder.read_image(); + //assert!(img_res.is_ok()); +} diff --git a/tests/images/COPYRIGHT b/tests/images/COPYRIGHT new file mode 100644 index 0000000..8282186 --- /dev/null +++ b/tests/images/COPYRIGHT @@ -0,0 +1,21 @@ +Copyright (c) 1988-1997 Sam Leffler +Copyright (c) 1991-1997 Silicon Graphics, Inc. + +Permission to use, copy, modify, distribute, and sell this software and +its documentation for any purpose is hereby granted without fee, provided +that (i) the above copyright notices and this permission notice appear in +all copies of the software and related documentation, and (ii) the names of +Sam Leffler and Silicon Graphics may not be used in any advertising or +publicity relating to the software without the specific, prior written +permission of Sam Leffler and Silicon Graphics. + +THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, +EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY +WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + +IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR +ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, +OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF +LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE +OF THIS SOFTWARE. diff --git a/tests/images/README.txt b/tests/images/README.txt new file mode 100644 index 0000000..17f6292 --- /dev/null +++ b/tests/images/README.txt @@ -0,0 +1,29 @@ +The test files in this directory mostly have dimension 157x151. +The naming convention is + + photometric-channels-bits.tiff + +minisblack-1c-16b.tiff +minisblack-1c-8b.tiff +miniswhite-1c-1b.tiff +palette-1c-1b.tiff +palette-1c-4b.tiff +palette-1c-8b.tiff +rgb-3c-16b.tiff +rgb-3c-8b.tiff + +logluv-3c-16b.tiff: logluv compression/photometric interp +minisblack-2c-8b-alpha.tiff: grey+alpha + +BMP files (anchient BMPv2 since v3 does not work): + + palette-1c-8b.bmp + rgb-3c-8b.bmp + +GIF files (anchient GIF '87 since modern GIF does not work): + palette-1c-8b.gif + +PNM files: + minisblack-1c-8b.pgm + miniswhite-1c-1b.pbm + rgb-3c-8b.ppm diff --git a/tests/images/logluv-3c-16b.tiff b/tests/images/logluv-3c-16b.tiff new file mode 100644 index 0000000..d43680f Binary files /dev/null and b/tests/images/logluv-3c-16b.tiff differ diff --git a/tests/images/minisblack-1c-16b.tiff b/tests/images/minisblack-1c-16b.tiff new file mode 100644 index 0000000..a8dbae7 Binary files /dev/null and b/tests/images/minisblack-1c-16b.tiff differ diff --git a/tests/images/minisblack-1c-8b.pgm b/tests/images/minisblack-1c-8b.pgm new file mode 100644 index 0000000..0faca40 Binary files /dev/null and b/tests/images/minisblack-1c-8b.pgm differ diff --git a/tests/images/minisblack-1c-8b.tiff b/tests/images/minisblack-1c-8b.tiff new file mode 100644 index 0000000..ea0f9ac Binary files /dev/null and b/tests/images/minisblack-1c-8b.tiff differ diff --git a/tests/images/minisblack-2c-8b-alpha.tiff b/tests/images/minisblack-2c-8b-alpha.tiff new file mode 100644 index 0000000..5fe8f58 Binary files /dev/null and b/tests/images/minisblack-2c-8b-alpha.tiff differ diff --git a/tests/images/miniswhite-1c-1b.pbm b/tests/images/miniswhite-1c-1b.pbm new file mode 100644 index 0000000..6cff929 Binary files /dev/null and b/tests/images/miniswhite-1c-1b.pbm differ diff --git a/tests/images/miniswhite-1c-1b.tiff b/tests/images/miniswhite-1c-1b.tiff new file mode 100644 index 0000000..bfc0838 Binary files /dev/null and b/tests/images/miniswhite-1c-1b.tiff differ diff --git a/tests/images/palette-1c-1b.tiff b/tests/images/palette-1c-1b.tiff new file mode 100644 index 0000000..25a1a32 Binary files /dev/null and b/tests/images/palette-1c-1b.tiff differ diff --git a/tests/images/palette-1c-4b.tiff b/tests/images/palette-1c-4b.tiff new file mode 100644 index 0000000..38ba325 Binary files /dev/null and b/tests/images/palette-1c-4b.tiff differ diff --git a/tests/images/palette-1c-8b.tiff b/tests/images/palette-1c-8b.tiff new file mode 100644 index 0000000..b87685a Binary files /dev/null and b/tests/images/palette-1c-8b.tiff differ diff --git a/tests/images/quad-lzw-compat.tiff b/tests/images/quad-lzw-compat.tiff new file mode 100644 index 0000000..ec614bf Binary files /dev/null and b/tests/images/quad-lzw-compat.tiff differ diff --git a/tests/images/quad-tile.jpg.tiff b/tests/images/quad-tile.jpg.tiff new file mode 100644 index 0000000..99b0bc2 Binary files /dev/null and b/tests/images/quad-tile.jpg.tiff differ diff --git a/tests/images/rgb-3c-16b.tiff b/tests/images/rgb-3c-16b.tiff new file mode 100644 index 0000000..f1a0279 Binary files /dev/null and b/tests/images/rgb-3c-16b.tiff differ diff --git a/tests/images/rgb-3c-8b.ppm b/tests/images/rgb-3c-8b.ppm new file mode 100644 index 0000000..6eca035 Binary files /dev/null and b/tests/images/rgb-3c-8b.ppm differ diff --git a/tests/images/rgb-3c-8b.tiff b/tests/images/rgb-3c-8b.tiff new file mode 100644 index 0000000..f64d404 Binary files /dev/null and b/tests/images/rgb-3c-8b.tiff differ