Debian Codegraph @

.cargo/vendor/tiff/tests/decode_bigtiff_images.rs

raw
1 extern crate tiff;
2
3 use tiff::decoder::Decoder;
4 use tiff::tags::Tag;
5 use tiff::ColorType;
6
7 use std::fs::File;
8 use std::path::PathBuf;
9
10 const TEST_IMAGE_DIR: &str = "./tests/images/bigtiff";
11
12 #[test]
13 fn test_big_tiff() {
14 let filenames = ["BigTIFF.tif", "BigTIFFMotorola.tif", "BigTIFFLong.tif"];
15 for filename in filenames.iter() {
16 let path = PathBuf::from(TEST_IMAGE_DIR).join(filename);
17 let img_file = File::open(path).expect("Cannot find test image!");
18 let mut decoder = Decoder::new(img_file).expect("Cannot create decoder");
19 assert_eq!(
20 decoder.dimensions().expect("Cannot get dimensions"),
21 (64, 64)
22 );
23 assert_eq!(
24 decoder.colortype().expect("Cannot get colortype"),
25 ColorType::RGB(8)
26 );
27 assert_eq!(
28 decoder
29 .get_tag_u64(Tag::StripOffsets)
30 .expect("Cannot get StripOffsets"),
31 16
32 );
33 assert_eq!(
34 decoder
35 .get_tag_u64(Tag::RowsPerStrip)
36 .expect("Cannot get RowsPerStrip"),
37 64
38 );
39 assert_eq!(
40 decoder
41 .get_tag_u64(Tag::StripByteCounts)
42 .expect("Cannot get StripByteCounts"),
43 12288
44 )
45 }
46 }