Debian Codegraph @

tests/decode_images.rs

raw symbols ◀ ▶ SCIP
1 Debian patch touch this file
1 extern crate tiffrust-analyzer cargo tiff 0.11.3 tiff/;
2
3 use tiffrust-analyzer cargo tiff 0.11.3 crate/::decoderrust-analyzer cargo tiff 0.11.3 decoder/::{ifdrust-analyzer cargo tiff 0.11.3 decoder/ifd/, Decoderrust-analyzer cargo tiff 0.11.3 decoder/Decoder#, DecodingResultrust-analyzer cargo tiff 0.11.3 decoder/DecodingResult#};
4 use tiffrust-analyzer cargo tiff 0.11.3 crate/::ColorTyperust-analyzer cargo tiff 0.11.3 ColorType#;
5
6 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::fsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/::Filerust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/File#;
7 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::{Readrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Read#, Seekrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Seek#};
8 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::pathrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/::PathBufrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/PathBuf#;
9
10 const TEST_IMAGE_DIRrust-analyzer cargo tiff 0.11.3 TEST_IMAGE_DIR.: &str = "./tests/images/";
11
12 macro_rules! test_image_sumrust-analyzer cargo tiff 0.11.3 test_image_sum! {
13 ($name:ident, $buffer:ident, $sum_ty:ty) => {
14 fn $name(file: &str, expected_type: ColorType, expected_sum: $sum_ty) {
15 let path = PathBuf::from(TEST_IMAGE_DIR).join(file);
16 let img_file = File::open(path).expect("Cannot find test image!");
17 let mut decoder = Decoder::new(img_file).expect("Cannot create decoder");
18 assert_eq!(decoder.colortype().unwrap(), expected_type);
19 let img_res = decoder.read_image().unwrap();
20
21 match img_res {
22 DecodingResult::$buffer(res) => {
23 let sum: $sum_ty = res.into_iter().map(<$sum_ty>::from).sum();
24 assert_eq!(sum, expected_sum);
25 }
26 _ => panic!("Wrong bit depth"),
27 }
28 }
29 };
30 }
31
32 test_image_sumrust-analyzer cargo tiff 0.11.3 test_image_sum!!(test_image_sum_u8rust-analyzer cargo tiff 0.11.3 test_image_sum_u8()., U8rust-analyzer cargo tiff 0.11.3 decoder/DecodingResult#U8#, u64);
33 test_image_sumrust-analyzer cargo tiff 0.11.3 test_image_sum!!(test_image_sum_i8rust-analyzer cargo tiff 0.11.3 test_image_sum_i8()., I8rust-analyzer cargo tiff 0.11.3 decoder/DecodingResult#I8#, i64);
34 test_image_sumrust-analyzer cargo tiff 0.11.3 test_image_sum!!(test_image_sum_u16rust-analyzer cargo tiff 0.11.3 test_image_sum_u16()., U16rust-analyzer cargo tiff 0.11.3 decoder/DecodingResult#U16#, u64);
35 test_image_sumrust-analyzer cargo tiff 0.11.3 test_image_sum!!(test_image_sum_i16rust-analyzer cargo tiff 0.11.3 test_image_sum_i16()., I16rust-analyzer cargo tiff 0.11.3 decoder/DecodingResult#I16#, i64);
36 test_image_sumrust-analyzer cargo tiff 0.11.3 test_image_sum!!(test_image_sum_u32rust-analyzer cargo tiff 0.11.3 test_image_sum_u32()., U32rust-analyzer cargo tiff 0.11.3 decoder/DecodingResult#U32#, u64);
37 test_image_sumrust-analyzer cargo tiff 0.11.3 test_image_sum!!(test_image_sum_u64rust-analyzer cargo tiff 0.11.3 test_image_sum_u64()., U64rust-analyzer cargo tiff 0.11.3 decoder/DecodingResult#U64#, u64);
38 test_image_sumrust-analyzer cargo tiff 0.11.3 test_image_sum!!(test_image_sum_f32rust-analyzer cargo tiff 0.11.3 test_image_sum_f32()., F32rust-analyzer cargo tiff 0.11.3 decoder/DecodingResult#F32#, f32);
39 test_image_sumrust-analyzer cargo tiff 0.11.3 test_image_sum!!(test_image_sum_f64rust-analyzer cargo tiff 0.11.3 test_image_sum_f64()., F64rust-analyzer cargo tiff 0.11.3 decoder/DecodingResult#F64#, f64);
40
41 /// Tests that a decoder can be constructed for an image and the color type
42 /// read from the IFD and is of the appropriate type, but the type is
43 /// unsupported.
44 fn test_image_color_type_unsupportedrust-analyzer cargo tiff 0.11.3 test_image_color_type_unsupported().(file: &str, expected_type: ColorTyperust-analyzer cargo tiff 0.11.3 ColorType#) {
45 let path = PathBufrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/PathBuf#::fromrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[PathBuf][`From<&T>`]from().(TEST_IMAGE_DIRrust-analyzer cargo tiff 0.11.3 TEST_IMAGE_DIR.).joinrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[Path]join().(file);
46 let img_file = Filerust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/File#::openrust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/impl#[File]open().(path).expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]expect().("Cannot find test image!");
47 let mut decoder = Decoderrust-analyzer cargo tiff 0.11.3 decoder/Decoder#::newrust-analyzer cargo tiff 0.11.3 decoder/impl#[`Decoder<R>`]new().(img_file).expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]expect().("Cannot create decoder");
48 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(decoder.colortyperust-analyzer cargo tiff 0.11.3 decoder/impl#[`Decoder<R>`]colortype().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(), expected_type);
49 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(matchesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/matches!!(
50 decoder.read_imagerust-analyzer cargo tiff 0.11.3 decoder/impl#[`Decoder<R>`]read_image().(),
51 Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(tiffrust-analyzer cargo tiff 0.11.3 crate/::TiffErrorrust-analyzer cargo tiff 0.11.3 error/TiffError#::UnsupportedErrorrust-analyzer cargo tiff 0.11.3 error/TiffError#UnsupportedError#(
52 tiffrust-analyzer cargo tiff 0.11.3 crate/::TiffUnsupportedErrorrust-analyzer cargo tiff 0.11.3 error/TiffUnsupportedError#::UnsupportedColorTyperust-analyzer cargo tiff 0.11.3 error/TiffUnsupportedError#UnsupportedColorType#(_),
53 ))
54 ));
55 }
•56 /*
57 #[test]
58 fn test_cmyk_u8() {
59 test_image_sum_u8("cmyk-3c-8b.tiff", ColorType::CMYK(8), 8522658);
60 }
61
62 #[test]
63 fn test_cmyk_u16() {
64 test_image_sum_u16("cmyk-3c-16b.tiff", ColorType::CMYK(16), 2181426827);
65 }
66
67 #[test]
68 fn test_cmyk_f32() {
69 test_image_sum_f32("cmyk-3c-32b-float.tiff", ColorType::CMYK(32), 496.0405);
70 }
71
72 #[test]
73 fn test_gray_u8() {
74 test_image_sum_u8("minisblack-1c-8b.tiff", ColorType::Gray(8), 2840893);
75 }
76
77 #[test]
78 fn test_gray_u12() {
79 test_image_color_type_unsupported("12bit.cropped.tiff", ColorType::Gray(12));
80 }
81
82 #[test]
83 fn test_gray_u16() {
84 test_image_sum_u16("minisblack-1c-16b.tiff", ColorType::Gray(16), 733126239);
85 }
86
87 #[test]
88 fn test_gray_u32() {
89 test_image_sum_u32("gradient-1c-32b.tiff", ColorType::Gray(32), 549892913787);
90 }
91
92 #[test]
93 fn test_gray_u64() {
94 test_image_sum_u64("gradient-1c-64b.tiff", ColorType::Gray(64), 549892913787);
95 }
96
97 #[test]
98 fn test_gray_f32() {
99 test_image_sum_f32("gradient-1c-32b-float.tiff", ColorType::Gray(32), 128.03194);
100 }
101
102 #[test]
103 fn test_gray_f64() {
104 test_image_sum_f64(
105 "gradient-1c-64b-float.tiff",
106 ColorType::Gray(64),
107 128.0319210877642,
108 );
109 }
110
111 #[test]
112 fn test_rgb_u8() {
113 test_image_sum_u8("rgb-3c-8b.tiff", ColorType::RGB(8), 7842108);
114 }
115
116 #[test]
117 fn test_rgb_u12() {
118 test_image_color_type_unsupported("12bit.cropped.rgb.tiff", ColorType::RGB(12));
119 }
120
121 #[test]
122 fn test_rgb_u16() {
123 test_image_sum_u16("rgb-3c-16b.tiff", ColorType::RGB(16), 2024349944);
124 }
125
126 #[test]
127 fn test_rgb_u32() {
128 test_image_sum_u32("gradient-3c-32b.tiff", ColorType::RGB(32), 2030834111716);
129 }
130
131 #[test]
132 fn test_rgb_u64() {
133 test_image_sum_u64("gradient-3c-64b.tiff", ColorType::RGB(64), 2030834111716);
134 }
135
136 #[test]
137 fn test_rgb_f32() {
138 test_image_sum_f32("gradient-3c-32b-float.tiff", ColorType::RGB(32), 472.8405);
139 }
140
141 #[test]
142 fn test_int8() {
143 test_image_sum_i8("int8.tif", ColorType::Gray(8), 3111)
144 }
145
146 #[test]
147 fn test_int8_rgb() {
148 test_image_sum_i8("int8_rgb.tif", ColorType::RGB(8), -10344)
149 }
150
151 #[test]
152 fn test_int16() {
153 test_image_sum_i16("int16.tif", ColorType::Gray(16), 354396);
154 }
155
156 #[test]
157 fn test_int16_rgb() {
158 test_image_sum_i16("int16_rgb.tif", ColorType::RGB(16), 1063188);
159 }
160
161 #[test]
162 fn test_string_tags() {
163 // these files have null-terminated strings for their Software tag. One has extra bytes after
164 // the null byte, so we check both to ensure that we're truncating properly
165 let filenames = ["minisblack-1c-16b.tiff", "rgb-3c-16b.tiff"];
166 for filename in filenames.iter() {
167 let path = PathBuf::from(TEST_IMAGE_DIR).join(filename);
168 let img_file = File::open(path).expect("Cannot find test image!");
169 let mut decoder = Decoder::new(img_file).expect("Cannot create decoder");
170 let software = decoder.get_tag(tiff::tags::Tag::Software).unwrap();
171 match software {
172 ifd::Value::Ascii(s) => assert_eq!(
173 &s,
174 "GraphicsMagick 1.2 unreleased Q16 http://www.GraphicsMagick.org/"
175 ),
176 other => unreachable!("Expected Ascii tag from file, got {other:?}"),
177 };
178 }
179 }
•180 */
181 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
182 fn test_decode_datarust-analyzer cargo tiff 0.11.3 test_decode_data().() {
183 let mut image_data = Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T>`]new().();
184 for x in 0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#100 {
185 for y in 0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#100u8 {
186 let val = x rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u8][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u8][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u8][`Add<Self>`]add().y;
187 image_data.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(val);
188 image_data.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(val);
189 image_data.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(val);
190 }
191 }
192 let file = Filerust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/File#::openrust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/impl#[File]open().("./tests/decodedata-rgb-3c-8b.tiff").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
193 let mut decoder = Decoderrust-analyzer cargo tiff 0.11.3 decoder/Decoder#::newrust-analyzer cargo tiff 0.11.3 decoder/impl#[`Decoder<R>`]new().(file).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
194 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(decoder.colortyperust-analyzer cargo tiff 0.11.3 decoder/impl#[`Decoder<R>`]colortype().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(), ColorTyperust-analyzer cargo tiff 0.11.3 ColorType#::RGBrust-analyzer cargo tiff 0.11.3 ColorType#RGB#(8));
195 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(decoder.dimensionsrust-analyzer cargo tiff 0.11.3 decoder/impl#[`Decoder<R>`]dimensions().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(), (100, 100));
196 if let DecodingResultrust-analyzer cargo tiff 0.11.3 decoder/DecodingResult#::U8rust-analyzer cargo tiff 0.11.3 decoder/DecodingResult#U8#(img_res) = decoder.read_imagerust-analyzer cargo tiff 0.11.3 decoder/impl#[`Decoder<R>`]read_image().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().() {
197 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(image_data, img_res);
198 } else {
199 panicrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/panic!!("Wrong data type");
200 }
201 }
202
203 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
•204 #[ignore = "skipping, missing testdata"]
205 fn issue_69rust-analyzer cargo tiff 0.11.3 issue_69().() {
206 test_image_sum_u16rust-analyzer cargo tiff 0.11.3 test_image_sum_u16().("issue_69_lzw.tiff", ColorTyperust-analyzer cargo tiff 0.11.3 ColorType#::Grayrust-analyzer cargo tiff 0.11.3 ColorType#Gray#(16), 1015486);
207 test_image_sum_u16rust-analyzer cargo tiff 0.11.3 test_image_sum_u16().("issue_69_packbits.tiff", ColorTyperust-analyzer cargo tiff 0.11.3 ColorType#::Grayrust-analyzer cargo tiff 0.11.3 ColorType#Gray#(16), 1015486);
208 }
209
210 // TODO: GrayA support
211 //#[test]
212 //fn test_gray_alpha_u8()
213 //{
214 //let img_file = File::open("./tests/images/minisblack-2c-8b-alpha.tiff").expect("Cannot find test image!");
215 //let mut decoder = Decoder::new(img_file).expect("Cannot create decoder");
216 //assert_eq!(decoder.colortype().unwrap(), ColorType::GrayA(8));
217 //let img_res = decoder.read_image();
218 //assert!(img_res.is_ok());
219 //}
220
221 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
•222 #[ignore = "skipping, missing testdata"]
223 fn test_tiled_gray_i1rust-analyzer cargo tiff 0.11.3 test_tiled_gray_i1().() {
224 test_image_sum_u8rust-analyzer cargo tiff 0.11.3 test_image_sum_u8().("tiled-gray-i1.tif", ColorTyperust-analyzer cargo tiff 0.11.3 ColorType#::Grayrust-analyzer cargo tiff 0.11.3 ColorType#Gray#(1), 30531);
225 }
226
227 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
•228 #[ignore = "skipping, missing testdata"]
229 fn test_tiled_rgb_u8rust-analyzer cargo tiff 0.11.3 test_tiled_rgb_u8().() {
230 test_image_sum_u8rust-analyzer cargo tiff 0.11.3 test_image_sum_u8().("tiled-rgb-u8.tif", ColorTyperust-analyzer cargo tiff 0.11.3 ColorType#::RGBrust-analyzer cargo tiff 0.11.3 ColorType#RGB#(8), 39528948);
231 }
232
233 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
•234 #[ignore = "skipping, missing testdata"]
235 fn test_tiled_rect_rgb_u8rust-analyzer cargo tiff 0.11.3 test_tiled_rect_rgb_u8().() {
236 test_image_sum_u8rust-analyzer cargo tiff 0.11.3 test_image_sum_u8().("tiled-rect-rgb-u8.tif", ColorTyperust-analyzer cargo tiff 0.11.3 ColorType#::RGBrust-analyzer cargo tiff 0.11.3 ColorType#RGB#(8), 62081032);
237 }
238
239 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
•240 #[ignore = "skipping, missing test data"]
241 fn test_inner_accessrust-analyzer cargo tiff 0.11.3 test_inner_access().() {
242 let path = PathBufrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/PathBuf#::fromrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[PathBuf][`From<&T>`]from().(TEST_IMAGE_DIRrust-analyzer cargo tiff 0.11.3 TEST_IMAGE_DIR.).joinrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[Path]join().("tiled-rect-rgb-u8.tif");
243 let img_file = Filerust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/File#::openrust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/impl#[File]open().(path).expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]expect().("Cannot find test image!");
244 let mut decoder = Decoderrust-analyzer cargo tiff 0.11.3 decoder/Decoder#::newrust-analyzer cargo tiff 0.11.3 decoder/impl#[`Decoder<R>`]new().(img_file).expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]expect().("Cannot create decoder");
245 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(decoder.colortyperust-analyzer cargo tiff 0.11.3 decoder/impl#[`Decoder<R>`]colortype().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(), ColorTyperust-analyzer cargo tiff 0.11.3 ColorType#::RGBrust-analyzer cargo tiff 0.11.3 ColorType#RGB#(8));
246
247 let c = decoder
248 .get_tagrust-analyzer cargo tiff 0.11.3 decoder/impl#[`Decoder<R>`]get_tag().(tiffrust-analyzer cargo tiff 0.11.3 crate/::tagsrust-analyzer cargo tiff 0.11.3 tags/::Tagrust-analyzer cargo tiff 0.11.3 tags/Tag#::Compressionrust-analyzer cargo tiff 0.11.3 tags/Tag#Compression#)
249 .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().()
250 .into_u16rust-analyzer cargo tiff 0.11.3 decoder/ifd/impl#[Value]into_u16().()
251 .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
252 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(c, tiffrust-analyzer cargo tiff 0.11.3 crate/::tagsrust-analyzer cargo tiff 0.11.3 tags/::CompressionMethodrust-analyzer cargo tiff 0.11.3 tags/CompressionMethod#::Nonerust-analyzer cargo tiff 0.11.3 tags/CompressionMethod#None#.to_u16rust-analyzer cargo tiff 0.11.3 tags/impl#[CompressionMethod]to_u16().());
253
254 // Because the image is uncompressed, reading the first tile directly with the inner reader
255 // should yield the same result as reading it with the decoder's read_chunk method.
256 let first_offset = decoder
257 .get_tag_u32_vecrust-analyzer cargo tiff 0.11.3 decoder/impl#[`Decoder<R>`]get_tag_u32_vec().(tiffrust-analyzer cargo tiff 0.11.3 crate/::tagsrust-analyzer cargo tiff 0.11.3 tags/::Tagrust-analyzer cargo tiff 0.11.3 tags/Tag#::TileOffsetsrust-analyzer cargo tiff 0.11.3 tags/Tag#TileOffsets#)
258 .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().()
259 .into_iterrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][IntoIterator]into_iter().()
260 .nextrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/into_iter/impl#[`IntoIter<T, A>`][Iterator]next().()
261 .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().();
262 let first_byte_count = decoder
263 .get_tag_u32_vecrust-analyzer cargo tiff 0.11.3 decoder/impl#[`Decoder<R>`]get_tag_u32_vec().(tiffrust-analyzer cargo tiff 0.11.3 crate/::tagsrust-analyzer cargo tiff 0.11.3 tags/::Tagrust-analyzer cargo tiff 0.11.3 tags/Tag#::TileByteCountsrust-analyzer cargo tiff 0.11.3 tags/Tag#TileByteCounts#)
264 .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().()
265 .into_iterrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][IntoIterator]into_iter().()
266 .nextrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/into_iter/impl#[`IntoIter<T, A>`][Iterator]next().()
267 .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().();
268 decoder
269 .innerrust-analyzer cargo tiff 0.11.3 decoder/impl#[`Decoder<R>`]inner().()
270 .seekrust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/impl#[File][Seek]seek().(stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::SeekFromrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/SeekFrom#::Startrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/SeekFrom#Start#(first_offset as u64))
271 .expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]expect().("Cannot seek to tile offset");
272 let mut buf = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![0; first_byte_count as usize];
273 decoder
274 .innerrust-analyzer cargo tiff 0.11.3 decoder/impl#[`Decoder<R>`]inner().()
275 .read_exactrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Read#read_exact().(&mut buf)
276 .expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]expect().("Cannot read tile data");
277 let raw_sum: u64 = buf.into_iterrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][IntoIterator]into_iter().().maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(<u64>::fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/num/impl#[u64][`From<u8>`]from().).sumrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#sum().();
278
279 match decoder.read_chunkrust-analyzer cargo tiff 0.11.3 decoder/impl#[`Decoder<R>`]read_chunk().(0).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().() {
280 DecodingResultrust-analyzer cargo tiff 0.11.3 decoder/DecodingResult#::U8rust-analyzer cargo tiff 0.11.3 decoder/DecodingResult#U8#(chunk) => {
281 let sum: u64 = chunk.into_iterrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][IntoIterator]into_iter().().maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(<u64>::fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/num/impl#[u64][`From<u8>`]from().).sumrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#sum().();
282 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(sum, raw_sum);
283 }
284 _ => panicrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/panic!!("Wrong bit depth"),
285 }
286 }
287
288 /* #[test]
289 fn test_tiled_jpeg_rgb_u8() {
290 test_image_sum_u8("tiled-jpeg-rgb-u8.tif", ColorType::RGB(8), 93031606);
291 } */
292
293 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
•294 #[ignore = "skipping, missing testdata"]
295 fn test_tiled_oversize_gray_i8rust-analyzer cargo tiff 0.11.3 test_tiled_oversize_gray_i8().() {
296 test_image_sum_i8rust-analyzer cargo tiff 0.11.3 test_image_sum_i8().("tiled-oversize-gray-i8.tif", ColorTyperust-analyzer cargo tiff 0.11.3 ColorType#::Grayrust-analyzer cargo tiff 0.11.3 ColorType#Gray#(8), 1214996);
297 }
298
299 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
•300 #[ignore = "skipping, missing testdata"]
301 fn test_tiled_cmyk_i8rust-analyzer cargo tiff 0.11.3 test_tiled_cmyk_i8().() {
302 test_image_sum_i8rust-analyzer cargo tiff 0.11.3 test_image_sum_i8().("tiled-cmyk-i8.tif", ColorTyperust-analyzer cargo tiff 0.11.3 ColorType#::CMYKrust-analyzer cargo tiff 0.11.3 ColorType#CMYK#(8), 1759101);
303 }
304
305 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
•306 #[ignore = "skipping, missing testdata"]
307 fn test_tiled_incrementalrust-analyzer cargo tiff 0.11.3 test_tiled_incremental().() {
308 let file = "tiled-rgb-u8.tif";
309 let expected_type = ColorTyperust-analyzer cargo tiff 0.11.3 ColorType#::RGBrust-analyzer cargo tiff 0.11.3 ColorType#RGB#(8);
310 let sums = [
311 188760, 195639, 108148, 81986, 665088, 366140, 705317, 423366, 172033, 324455, 244102,
312 81853, 181258, 247971, 129486, 55600, 565625, 422102, 730888, 379271, 232142, 292549,
313 244045, 86866, 188141, 115036, 150785, 84389, 353170, 459325, 719619, 329594, 278663,
314 220474, 243048, 113563, 189152, 109684, 179391, 122188, 279651, 622093, 724682, 302459,
315 268428, 204499, 224255, 124674, 170668, 121868, 192768, 183367, 378029, 585651, 657712,
316 296790, 241444, 197083, 198429, 134869, 182318, 86034, 203655, 182338, 297255, 601284,
317 633813, 242531, 228578, 206441, 193552, 125412, 181527, 165439, 202531, 159538, 268388,
318 565790, 611382, 272967, 236497, 215154, 158881, 90806, 106114, 182342, 191824, 186138,
319 215174, 393193, 701228, 198866, 227944, 193830, 166330, 49008, 55719, 122820, 197316,
320 161969, 203152, 170986, 624427, 188605, 186187, 111064, 115192, 39538, 48626, 163929,
321 144682, 135796, 194141, 154198, 584125, 180255, 153524, 121433, 132641, 35743, 47798,
322 152343, 162874, 167664, 160175, 133038, 659882, 138339, 166470, 124173, 118929, 51317,
323 45267, 155776, 161331, 161006, 130052, 137618, 337291, 106481, 161999, 127343, 87724,
324 59540, 63907, 155677, 140668, 141523, 108061, 168657, 186482, 98599, 147614, 139963, 90444,
325 56602, 92547, 125644, 134212, 126569, 144153, 179800, 174516, 133969, 129399, 117681,
326 83305, 55075, 110737, 115108, 128572, 128911, 130922, 179986, 143288, 145884, 155856,
327 96683, 94057, 56238, 79649, 71651, 70182, 75010, 77009, 98855, 78979, 74341, 83482, 53403,
328 59842, 30305,
329 ];
330
331 let path = PathBufrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/PathBuf#::fromrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[PathBuf][`From<&T>`]from().(TEST_IMAGE_DIRrust-analyzer cargo tiff 0.11.3 TEST_IMAGE_DIR.).joinrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[Path]join().(file);
332 let img_file = Filerust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/File#::openrust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/impl#[File]open().(path).expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]expect().("Cannot find test image!");
333 let mut decoder = Decoderrust-analyzer cargo tiff 0.11.3 decoder/Decoder#::newrust-analyzer cargo tiff 0.11.3 decoder/impl#[`Decoder<R>`]new().(img_file).expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]expect().("Cannot create decoder");
334 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(decoder.colortyperust-analyzer cargo tiff 0.11.3 decoder/impl#[`Decoder<R>`]colortype().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(), expected_type);
335
336 let tiles = decoder.tile_countrust-analyzer cargo tiff 0.11.3 decoder/impl#[`Decoder<R>`]tile_count().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
337 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(tiles as usize, sums.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().());
338
339 for tile in 0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#tiles {
340 match decoder.read_chunkrust-analyzer cargo tiff 0.11.3 decoder/impl#[`Decoder<R>`]read_chunk().(tile).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().() {
341 DecodingResultrust-analyzer cargo tiff 0.11.3 decoder/DecodingResult#::U8rust-analyzer cargo tiff 0.11.3 decoder/DecodingResult#U8#(res) => {
342 let sum: u64 = res.into_iterrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][IntoIterator]into_iter().().maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(<u64>::fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/num/impl#[u64][`From<u8>`]from().).sumrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#sum().();
343 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(sum, sums[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index().tile as usize]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index().);
344 }
345 _ => panicrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/panic!!("Wrong bit depth"),
346 }
347 }
348 }
349
350 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
•351 #[ignore = "skipping, missing test data"]
352 fn test_planar_rgb_u8rust-analyzer cargo tiff 0.11.3 test_planar_rgb_u8().() {
353 test_image_sum_u8rust-analyzer cargo tiff 0.11.3 test_image_sum_u8().("planar-rgb-u8.tif", ColorTyperust-analyzer cargo tiff 0.11.3 ColorType#::RGBrust-analyzer cargo tiff 0.11.3 ColorType#RGB#(8), 15417630);
354 }
355
356 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
•357 #[ignore = "skipping, missing test data"]
358 fn test_read_planar_bandsrust-analyzer cargo tiff 0.11.3 test_read_planar_bands().() {
359 // gdal_translate tiled-rgb-u8.tif planar-rgb-u8.tif -co INTERLEAVE=BAND -co COMPRESS=LZW -co PROFILE=BASELINE
360 let file = "planar-rgb-u8.tif";
361 let expected_type = ColorTyperust-analyzer cargo tiff 0.11.3 ColorType#::RGBrust-analyzer cargo tiff 0.11.3 ColorType#RGB#(8);
362
363 let path = PathBufrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/PathBuf#::fromrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[PathBuf][`From<&T>`]from().(TEST_IMAGE_DIRrust-analyzer cargo tiff 0.11.3 TEST_IMAGE_DIR.).joinrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[Path]join().(file);
364 let img_file = Filerust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/File#::openrust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/impl#[File]open().(path).expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]expect().("Cannot find test image!");
365 let mut decoder = Decoderrust-analyzer cargo tiff 0.11.3 decoder/Decoder#::newrust-analyzer cargo tiff 0.11.3 decoder/impl#[`Decoder<R>`]new().(img_file).expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]expect().("Cannot create decoder");
366 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(decoder.colortyperust-analyzer cargo tiff 0.11.3 decoder/impl#[`Decoder<R>`]colortype().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(), expected_type);
367
368 let chunks = decoder.strip_countrust-analyzer cargo tiff 0.11.3 decoder/impl#[`Decoder<R>`]strip_count().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
369 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(chunks as usize, 72);
370
371 // convert -quiet planar-rgb-u8.tif[0] -crop 1x1+0+0 txt:
372 // 0,0: (73,51,30) #49331E srgb(73,51,30)
373
374 // 1st band (red)
375 match decoder.read_chunkrust-analyzer cargo tiff 0.11.3 decoder/impl#[`Decoder<R>`]read_chunk().(0).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().() {
376 DecodingResultrust-analyzer cargo tiff 0.11.3 decoder/DecodingResult#::U8rust-analyzer cargo tiff 0.11.3 decoder/DecodingResult#U8#(chunk) => {
377 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(chunk[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().0]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()., 73);
378 }
379 _ => panicrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/panic!!("Wrong bit depth"),
380 }
381 // 2nd band (green)
382 match decoder.read_chunkrust-analyzer cargo tiff 0.11.3 decoder/impl#[`Decoder<R>`]read_chunk().(chunks rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Div<Self>`]div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Div<Self>`]div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Div<Self>`]div().3).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().() {
383 DecodingResultrust-analyzer cargo tiff 0.11.3 decoder/DecodingResult#::U8rust-analyzer cargo tiff 0.11.3 decoder/DecodingResult#U8#(chunk) => {
384 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(chunk[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().0]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()., 51);
385 }
386 _ => panicrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/panic!!("Wrong bit depth"),
387 }
388 // 3rd band (blue)
389 match decoder.read_chunkrust-analyzer cargo tiff 0.11.3 decoder/impl#[`Decoder<R>`]read_chunk().(chunks rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Div<Self>`]div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Div<Self>`]div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Div<Self>`]div().3 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Mul<Self>`]mul().2).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().() {
390 DecodingResultrust-analyzer cargo tiff 0.11.3 decoder/DecodingResult#::U8rust-analyzer cargo tiff 0.11.3 decoder/DecodingResult#U8#(chunk) => {
391 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(chunk[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().0]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()., 30);
392 }
393 _ => panicrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/panic!!("Wrong bit depth"),
394 }
395 }
396
397 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
398 fn test_div_zerorust-analyzer cargo tiff 0.11.3 test_div_zero().() {
399 use tiffrust-analyzer cargo tiff 0.11.3 crate/::{TiffErrorrust-analyzer cargo tiff 0.11.3 error/TiffError#, TiffFormatErrorrust-analyzer cargo tiff 0.11.3 error/TiffFormatError#};
400
401 let image = [
402 73, 73, 42, 0, 8, 0, 0, 0, 8, 0, 0, 1, 4, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 40, 1, 0, 0,
403 0, 158, 0, 0, 251, 3, 1, 3, 0, 1, 0, 0, 0, 1, 0, 0, 39, 6, 1, 3, 0, 1, 0, 0, 0, 0, 0, 0, 0,
404 17, 1, 4, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 3, 0, 1, 0, 0, 0, 158, 0, 0, 251, 67, 1, 3, 0,
405 1, 0, 0, 0, 40, 0, 0, 0, 66, 1, 4, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 48, 178, 178, 178, 178,
406 178, 178, 178,
407 ];
408
409 let err = tiffrust-analyzer cargo tiff 0.11.3 crate/::decoderrust-analyzer cargo tiff 0.11.3 decoder/::Decoderrust-analyzer cargo tiff 0.11.3 decoder/Decoder#::newrust-analyzer cargo tiff 0.11.3 decoder/impl#[`Decoder<R>`]new().(stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Cursorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/cursor/Cursor#::newrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/cursor/impl#[`Cursor<T>`]new().(&image)).unwrap_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap_err().();
410
411 match err {
412 TiffErrorrust-analyzer cargo tiff 0.11.3 error/TiffError#::FormatErrorrust-analyzer cargo tiff 0.11.3 error/TiffError#FormatError#(TiffFormatErrorrust-analyzer cargo tiff 0.11.3 error/TiffFormatError#::StripTileTagConflictrust-analyzer cargo tiff 0.11.3 error/TiffFormatError#StripTileTagConflict#) => {}
413 unexpected => panicrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/panic!!("Unexpected error {unexpected}"),
414 }
415 }
416
417 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
418 fn test_too_many_value_bytesrust-analyzer cargo tiff 0.11.3 test_too_many_value_bytes().() {
419 let image = [
420 73, 73, 43, 0, 8, 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 0, 8, 0, 0, 0,
421 23, 0, 12, 0, 0, 65, 4, 0, 1, 6, 0, 0, 1, 16, 0, 1, 0, 0, 0, 0, 0, 0, 128, 0, 0, 0, 0, 0,
422 0, 0, 3, 0, 1, 0, 0, 0, 1, 0, 0, 0, 59, 73, 84, 186, 202, 83, 240, 66, 1, 53, 22, 56, 47,
423 0, 0, 0, 0, 0, 0, 1, 222, 4, 0, 58, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 4, 0, 0, 100, 0,
424 0, 89, 89, 89, 89, 89, 89, 89, 89, 96, 1, 20, 89, 89, 89, 89, 18,
425 ];
426
427 let error = tiffrust-analyzer cargo tiff 0.11.3 crate/::decoderrust-analyzer cargo tiff 0.11.3 decoder/::Decoderrust-analyzer cargo tiff 0.11.3 decoder/Decoder#::newrust-analyzer cargo tiff 0.11.3 decoder/impl#[`Decoder<R>`]new().(stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Cursorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/cursor/Cursor#::newrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/cursor/impl#[`Cursor<T>`]new().(&image)).unwrap_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap_err().();
428
429 match error {
430 tiffrust-analyzer cargo tiff 0.11.3 crate/::TiffErrorrust-analyzer cargo tiff 0.11.3 error/TiffError#::LimitsExceededrust-analyzer cargo tiff 0.11.3 error/TiffError#LimitsExceeded# => {}
431 unexpected => panicrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/panic!!("Unexpected error {unexpected}"),
432 }
433 }
434
435 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
436 fn fuzzer_testcase5rust-analyzer cargo tiff 0.11.3 fuzzer_testcase5().() {
437 let image = [
438 73, 73, 42, 0, 8, 0, 0, 0, 8, 0, 0, 1, 4, 0, 1, 0, 0, 0, 100, 0, 0, 0, 1, 1, 4, 0, 1, 0, 0,
439 0, 158, 0, 0, 251, 3, 1, 3, 0, 1, 0, 0, 0, 1, 0, 0, 0, 6, 1, 3, 0, 1, 0, 0, 0, 0, 0, 0, 0,
440 17, 1, 4, 0, 1, 0, 0, 0, 0, 0, 0, 0, 2, 1, 3, 0, 0, 0, 0, 0, 246, 16, 0, 0, 22, 1, 4, 0, 1,
441 0, 0, 0, 40, 0, 251, 255, 23, 1, 4, 0, 1, 0, 0, 0, 48, 178, 178, 178, 178, 178, 178, 178,
442 178, 178, 178,
443 ];
444
445 let _ = tiffrust-analyzer cargo tiff 0.11.3 crate/::decoderrust-analyzer cargo tiff 0.11.3 decoder/::Decoderrust-analyzer cargo tiff 0.11.3 decoder/Decoder#::newrust-analyzer cargo tiff 0.11.3 decoder/impl#[`Decoder<R>`]new().(stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Cursorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/cursor/Cursor#::newrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/cursor/impl#[`Cursor<T>`]new().(&image)).unwrap_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap_err().();
446 }
447
448 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
449 fn fuzzer_testcase1rust-analyzer cargo tiff 0.11.3 fuzzer_testcase1().() {
450 let image = [
451 73, 73, 42, 0, 8, 0, 0, 0, 8, 0, 0, 1, 4, 0, 1, 0, 0, 0, 99, 255, 255, 254, 1, 1, 4, 0, 1,
452 0, 0, 0, 158, 0, 0, 251, 3, 1, 3, 255, 254, 255, 255, 0, 1, 0, 0, 0, 6, 1, 3, 0, 1, 0, 0,
453 0, 0, 0, 0, 0, 17, 1, 4, 0, 9, 0, 0, 0, 0, 0, 0, 0, 2, 1, 3, 0, 2, 0, 0, 0, 63, 0, 0, 0,
454 22, 1, 4, 0, 1, 0, 0, 0, 44, 0, 0, 0, 23, 1, 4, 0, 0, 0, 0, 0, 0, 0, 2, 1, 3, 1, 0, 178,
455 178,
456 ];
457
458 let _ = tiffrust-analyzer cargo tiff 0.11.3 crate/::decoderrust-analyzer cargo tiff 0.11.3 decoder/::Decoderrust-analyzer cargo tiff 0.11.3 decoder/Decoder#::newrust-analyzer cargo tiff 0.11.3 decoder/impl#[`Decoder<R>`]new().(stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Cursorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/cursor/Cursor#::newrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/cursor/impl#[`Cursor<T>`]new().(&image)).unwrap_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap_err().();
459 }
460
461 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
462 fn fuzzer_testcase6rust-analyzer cargo tiff 0.11.3 fuzzer_testcase6().() {
463 let image = [
464 73, 73, 42, 0, 8, 0, 0, 0, 8, 0, 0, 1, 4, 0, 1, 0, 0, 0, 100, 0, 0, 148, 1, 1, 4, 0, 1, 0,
465 0, 0, 158, 0, 0, 251, 3, 1, 3, 255, 254, 255, 255, 0, 1, 0, 0, 0, 6, 1, 3, 0, 1, 0, 0, 0,
466 0, 0, 0, 0, 17, 1, 4, 0, 1, 0, 0, 0, 0, 0, 0, 0, 2, 1, 3, 0, 2, 0, 0, 0, 63, 0, 0, 0, 22,
467 1, 4, 0, 1, 0, 0, 0, 44, 0, 248, 255, 23, 1, 4, 0, 1, 0, 0, 0, 178, 178, 178, 0, 1, 178,
468 178, 178,
469 ];
470
471 let _ = tiffrust-analyzer cargo tiff 0.11.3 crate/::decoderrust-analyzer cargo tiff 0.11.3 decoder/::Decoderrust-analyzer cargo tiff 0.11.3 decoder/Decoder#::newrust-analyzer cargo tiff 0.11.3 decoder/impl#[`Decoder<R>`]new().(stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Cursorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/cursor/Cursor#::newrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/cursor/impl#[`Cursor<T>`]new().(&image)).unwrap_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap_err().();
472 }
473
474 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
475 fn oomrust-analyzer cargo tiff 0.11.3 oom().() {
476 let image = [
477 73, 73, 42, 0, 8, 0, 0, 0, 8, 0, 0, 1, 4, 0, 1, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 40, 1, 0, 0,
478 0, 158, 0, 0, 251, 3, 1, 3, 0, 1, 0, 0, 0, 7, 0, 0, 0, 6, 1, 3, 0, 1, 0, 0, 0, 2, 0, 0, 0,
479 17, 1, 4, 0, 1, 0, 0, 0, 3, 77, 0, 0, 1, 1, 3, 0, 1, 0, 0, 0, 3, 128, 0, 0, 22, 1, 4, 0, 1,
480 0, 0, 0, 40, 0, 0, 0, 23, 1, 4, 0, 1, 0, 0, 0, 178, 48, 178, 178, 178, 178, 162, 178,
481 ];
482
483 let _ = tiffrust-analyzer cargo tiff 0.11.3 crate/::decoderrust-analyzer cargo tiff 0.11.3 decoder/::Decoderrust-analyzer cargo tiff 0.11.3 decoder/Decoder#::newrust-analyzer cargo tiff 0.11.3 decoder/impl#[`Decoder<R>`]new().(stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Cursorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/cursor/Cursor#::newrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/cursor/impl#[`Cursor<T>`]new().(&image)).unwrap_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap_err().();
484 }
485
486 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
487 fn fuzzer_testcase4rust-analyzer cargo tiff 0.11.3 fuzzer_testcase4().() {
488 let image = [
489 73, 73, 42, 0, 8, 0, 0, 0, 8, 0, 0, 1, 4, 0, 1, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 40, 1, 0, 0,
490 0, 158, 0, 0, 251, 3, 1, 3, 0, 1, 0, 0, 0, 5, 0, 0, 0, 6, 1, 3, 0, 1, 0, 0, 0, 0, 0, 0, 0,
491 17, 1, 4, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 3, 0, 1, 0, 0, 0, 3, 128, 0, 0, 22, 1, 4, 0, 1,
492 0, 0, 0, 40, 0, 0, 0, 23, 1, 4, 0, 1, 0, 0, 0, 48, 178, 178, 178, 0, 1, 0, 13, 13,
493 ];
494
495 let _ = tiffrust-analyzer cargo tiff 0.11.3 crate/::decoderrust-analyzer cargo tiff 0.11.3 decoder/::Decoderrust-analyzer cargo tiff 0.11.3 decoder/Decoder#::newrust-analyzer cargo tiff 0.11.3 decoder/impl#[`Decoder<R>`]new().(stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Cursorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/cursor/Cursor#::newrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/cursor/impl#[`Cursor<T>`]new().(&image)).unwrap_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap_err().();
496 }
497
498 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
499 fn fuzzer_testcase2rust-analyzer cargo tiff 0.11.3 fuzzer_testcase2().() {
500 let image = [
501 73, 73, 42, 0, 8, 0, 0, 0, 15, 0, 0, 254, 44, 1, 0, 0, 0, 0, 0, 32, 0, 0, 0, 1, 4, 0, 1, 0,
502 0, 0, 0, 1, 0, 0, 91, 1, 1, 0, 0, 0, 0, 0, 242, 4, 0, 0, 0, 22, 0, 56, 77, 0, 77, 1, 0, 0,
503 73, 42, 0, 1, 4, 0, 1, 0, 0, 0, 4, 0, 8, 0, 0, 1, 4, 0, 1, 0, 0, 0, 158, 0, 0, 251, 3, 1,
504 3, 0, 1, 0, 0, 0, 7, 0, 0, 0, 6, 1, 3, 0, 1, 0, 0, 0, 2, 0, 0, 0, 17, 1, 4, 0, 1, 0, 0, 0,
505 0, 0, 0, 0, 1, 1, 3, 0, 1, 0, 0, 0, 0, 0, 0, 4, 61, 1, 18, 0, 1, 0, 0, 0, 202, 0, 0, 0, 17,
506 1, 100, 0, 129, 0, 0, 0, 0, 0, 0, 0, 232, 254, 252, 255, 254, 255, 255, 255, 1, 29, 0, 0,
507 22, 1, 3, 0, 1, 0, 0, 0, 16, 0, 0, 0, 23, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 123, 73, 254, 0,
508 73,
509 ];
510
511 let _ = tiffrust-analyzer cargo tiff 0.11.3 crate/::decoderrust-analyzer cargo tiff 0.11.3 decoder/::Decoderrust-analyzer cargo tiff 0.11.3 decoder/Decoder#::newrust-analyzer cargo tiff 0.11.3 decoder/impl#[`Decoder<R>`]new().(stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Cursorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/cursor/Cursor#::newrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/cursor/impl#[`Cursor<T>`]new().(&image)).unwrap_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap_err().();
512 }
513
514 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
515 fn invalid_jpeg_tag_2rust-analyzer cargo tiff 0.11.3 invalid_jpeg_tag_2().() {
516 let image = [
517 73, 73, 42, 0, 8, 0, 0, 0, 16, 0, 254, 0, 4, 0, 1, 0, 0, 0, 0, 0, 0, 242, 0, 1, 4, 0, 1, 0,
518 0, 0, 0, 129, 16, 0, 1, 1, 4, 0, 1, 0, 0, 0, 214, 0, 0, 248, 253, 1, 3, 0, 1, 0, 0, 0, 64,
519 0, 0, 0, 3, 1, 3, 0, 1, 0, 0, 0, 7, 0, 0, 0, 6, 1, 3, 0, 1, 0, 0, 0, 1, 0, 0, 64, 14, 1, 0,
520 2, 0, 0, 148, 0, 206, 0, 0, 0, 17, 1, 4, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0,
521 1, 0, 0, 0, 22, 1, 4, 0, 17, 0, 0, 201, 1, 0, 0, 0, 23, 1, 2, 0, 20, 0, 0, 0, 194, 0, 0, 0,
522 91, 1, 7, 0, 5, 0, 0, 0, 64, 0, 0, 0, 237, 254, 65, 255, 255, 255, 255, 255, 1, 0, 0, 0,
523 22, 1, 4, 0, 1, 0, 0, 0, 42, 0, 0, 0, 23, 1, 255, 255, 255, 255, 255, 36, 36, 0, 0, 0, 0,
524 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 36, 73, 73, 0, 42, 36, 36, 36, 36, 0, 0, 8, 0,
525 ];
526
527 let _ = tiffrust-analyzer cargo tiff 0.11.3 crate/::decoderrust-analyzer cargo tiff 0.11.3 decoder/::Decoderrust-analyzer cargo tiff 0.11.3 decoder/Decoder#::newrust-analyzer cargo tiff 0.11.3 decoder/impl#[`Decoder<R>`]new().(stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Cursorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/cursor/Cursor#::newrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/cursor/impl#[`Cursor<T>`]new().(&image)).unwrap_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap_err().();
528 }
529
530 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
531 fn fuzzer_testcase3rust-analyzer cargo tiff 0.11.3 fuzzer_testcase3().() {
532 let image = [
533 73, 73, 42, 0, 8, 0, 0, 0, 8, 0, 0, 1, 4, 0, 1, 0, 0, 0, 2, 0, 0, 0, 61, 1, 9, 0, 46, 22,
534 128, 0, 0, 0, 0, 1, 6, 1, 3, 0, 1, 0, 0, 0, 0, 0, 0, 0, 17, 1, 4, 0, 27, 0, 0, 0, 0, 0, 0,
535 0, 1, 1, 3, 0, 1, 0, 0, 0, 17, 1, 0, 231, 22, 1, 1, 0, 1, 0, 0, 0, 130, 0, 0, 0, 23, 1, 4,
536 0, 14, 0, 0, 0, 0, 0, 0, 0, 133, 133, 133, 77, 77, 77, 0, 0, 22, 128, 0, 255, 255, 255,
537 255, 255,
538 ];
539
540 let _ = tiffrust-analyzer cargo tiff 0.11.3 crate/::decoderrust-analyzer cargo tiff 0.11.3 decoder/::Decoderrust-analyzer cargo tiff 0.11.3 decoder/Decoder#::newrust-analyzer cargo tiff 0.11.3 decoder/impl#[`Decoder<R>`]new().(stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Cursorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/cursor/Cursor#::newrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/cursor/impl#[`Cursor<T>`]new().(&image)).unwrap_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap_err().();
541 }
542
543 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
544 fn timeoutrust-analyzer cargo tiff 0.11.3 timeout().() {
545 use tiffrust-analyzer cargo tiff 0.11.3 crate/::{TiffErrorrust-analyzer cargo tiff 0.11.3 error/TiffError#, TiffFormatErrorrust-analyzer cargo tiff 0.11.3 error/TiffFormatError#};
546
547 let image = [
548 73, 73, 42, 0, 8, 0, 0, 0, 16, 0, 254, 0, 4, 0, 1, 68, 0, 0, 0, 2, 0, 32, 254, 252, 0, 109,
549 0, 129, 0, 0, 0, 32, 0, 58, 0, 1, 4, 0, 1, 0, 6, 0, 0, 0, 8, 0, 0, 1, 73, 73, 42, 0, 8, 0,
550 0, 0, 8, 0, 0, 1, 4, 0, 1, 0, 0, 0, 21, 0, 0, 0, 61, 1, 255, 128, 9, 0, 0, 8, 0, 1, 113, 2,
551 3, 1, 3, 0, 1, 0, 0, 0, 5, 0, 65, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 112, 0, 0, 36, 0, 0,
552 0, 112, 56, 200, 0, 5, 0, 0, 64, 0, 0, 1, 0, 4, 0, 0, 0, 2, 0, 6, 1, 3, 0, 1, 0, 0, 0, 0,
553 0, 0, 4, 17, 1, 1, 0, 93, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 0, 0, 0, 3, 6, 0, 231, 22, 1,
554 1, 0, 1, 0, 0, 0, 2, 64, 118, 36, 23, 1, 1, 0, 43, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 4, 0, 8,
555 0, 0, 73, 73, 42, 0, 8, 0, 0, 0, 0, 0, 32,
556 ];
557
558 let error = tiffrust-analyzer cargo tiff 0.11.3 crate/::decoderrust-analyzer cargo tiff 0.11.3 decoder/::Decoderrust-analyzer cargo tiff 0.11.3 decoder/Decoder#::newrust-analyzer cargo tiff 0.11.3 decoder/impl#[`Decoder<R>`]new().(stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Cursorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/cursor/Cursor#::newrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/cursor/impl#[`Cursor<T>`]new().(&image)).unwrap_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap_err().();
559
560 match error {
561 TiffErrorrust-analyzer cargo tiff 0.11.3 error/TiffError#::FormatErrorrust-analyzer cargo tiff 0.11.3 error/TiffError#FormatError#(TiffFormatErrorrust-analyzer cargo tiff 0.11.3 error/TiffFormatError#::CycleInOffsetsrust-analyzer cargo tiff 0.11.3 error/TiffFormatError#CycleInOffsets#) => {}
562 e => panicrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/panic!!("Unexpected error {e:?}"),
563 }
564 }
565
566 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
•567 #[ignore = "skipping, missing testdata"]
568 fn test_no_rows_per_striprust-analyzer cargo tiff 0.11.3 test_no_rows_per_strip().() {
569 test_image_sum_u8rust-analyzer cargo tiff 0.11.3 test_image_sum_u8().("no_rows_per_strip.tiff", ColorTyperust-analyzer cargo tiff 0.11.3 ColorType#::RGBrust-analyzer cargo tiff 0.11.3 ColorType#RGB#(8), 99448840);
570 }
571
572 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
•573 #[ignore = "skipping, missing testdata"]
574 fn test_predictor_3_rgb_f32rust-analyzer cargo tiff 0.11.3 test_predictor_3_rgb_f32().() {
575 test_image_sum_f32rust-analyzer cargo tiff 0.11.3 test_image_sum_f32().("predictor-3-rgb-f32.tif", ColorTyperust-analyzer cargo tiff 0.11.3 ColorType#::RGBrust-analyzer cargo tiff 0.11.3 ColorType#RGB#(32), 54004.33);
576 }
577
578 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
•579 #[ignore = "skipping, missing testdata"]
580 fn test_predictor_3_gray_f32rust-analyzer cargo tiff 0.11.3 test_predictor_3_gray_f32().() {
581 test_image_sum_f32rust-analyzer cargo tiff 0.11.3 test_image_sum_f32().("predictor-3-gray-f32.tif", ColorTyperust-analyzer cargo tiff 0.11.3 ColorType#::Grayrust-analyzer cargo tiff 0.11.3 ColorType#Gray#(32), 20008.275);
582 }
583
584 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
585 #[cfg(feature = "zstd")]
•586 #[ignore = "skipping, missing testdata"]
587 fn test_zstd_compressionrust-analyzer cargo tiff 0.11.3 test_zstd_compression().() {
588 // gdal_translate -co COMPRESS=ZSTD -co ZSTD_LEVEL=20 int16.tif int16_zstd.tif
589 test_image_sum_i16rust-analyzer cargo tiff 0.11.3 test_image_sum_i16().("int16_zstd.tif", ColorTyperust-analyzer cargo tiff 0.11.3 ColorType#::Grayrust-analyzer cargo tiff 0.11.3 ColorType#Gray#(16), 354396);
590 }
591
592 fn test_image_bytesrust-analyzer cargo tiff 0.11.3 test_image_bytes().(
593 file: &str,
594 expected: &[(ColorTyperust-analyzer cargo tiff 0.11.3 ColorType#, u32)],
595 // Represent all samples as little endian, ensuring check sums on all platforms.
596 normalize_byte_order: fn(&mut [u8]),
597 ) {
598 let path = PathBufrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/PathBuf#::fromrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[PathBuf][`From<&T>`]from().(TEST_IMAGE_DIRrust-analyzer cargo tiff 0.11.3 TEST_IMAGE_DIR.).joinrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[Path]join().(file);
599 let img_file = Filerust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/File#::openrust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/impl#[File]open().(path).expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]expect().("Cannot find test image!");
600 let mut decoder = Decoderrust-analyzer cargo tiff 0.11.3 decoder/Decoder#::newrust-analyzer cargo tiff 0.11.3 decoder/impl#[`Decoder<R>`]new().(img_file).expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]expect().("Cannot create decoder");
601
602 let mut buffer = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![0u8; 0];
603 for (idx, &(expected_type, expected_crc)) in expected.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().().enumeraterust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#enumerate().() {
604 if idx rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt().>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt().0 {
605 decoder
606 .next_imagerust-analyzer cargo tiff 0.11.3 decoder/impl#[`Decoder<R>`]next_image().()
607 .expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]expect().("mismatched number of directories");
608 }
609
610 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(decoder.colortyperust-analyzer cargo tiff 0.11.3 decoder/impl#[`Decoder<R>`]colortype().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(), expected_type);
611 let layout = decoder
612 .image_buffer_layoutrust-analyzer cargo tiff 0.11.3 decoder/impl#[`Decoder<R>`]image_buffer_layout().()
613 .expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]expect().("Cannot describe buffer layout");
614
615 buffer.resizerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]resize().(layout.lenrust-analyzer cargo tiff 0.11.3 decoder/BufferLayoutPreference#len., 0u8);
616 decoder.read_image_bytesrust-analyzer cargo tiff 0.11.3 decoder/impl#[`Decoder<R>`]read_image_bytes().(&mut buffer).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
617 normalize_byte_order(&mut buffer);
618
619 // Well almost a crc..
620 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(crc32fastrust-analyzer cargo crc32fast 1.5.0 crate/::hashrust-analyzer cargo crc32fast 1.5.0 hash().(&buffer), expected_crc);
621 }
622 }
623
624 fn byte_order_u16rust-analyzer cargo tiff 0.11.3 byte_order_u16().(bytes: &mut [u8]) {
625 for chunk in bytes.chunks_exact_mutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]chunks_exact_mut().(2) {
626 let n = u16::from_ne_bytesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u16]from_ne_bytes().(chunk.try_intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/TryInto#try_into().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().());
627 chunk.copy_from_slicerust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]copy_from_slice().(&n.to_le_bytesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u16]to_le_bytes().());
628 }
629 }
630
631 fn byte_order_u32rust-analyzer cargo tiff 0.11.3 byte_order_u32().(bytes: &mut [u8]) {
632 for chunk in bytes.chunks_exact_mutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]chunks_exact_mut().(4) {
633 let n = u32::from_ne_bytesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u32]from_ne_bytes().(chunk.try_intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/TryInto#try_into().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().());
634 chunk.copy_from_slicerust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]copy_from_slice().(&n.to_le_bytesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u32]to_le_bytes().());
635 }
636 }
637
638 fn byte_order_u64rust-analyzer cargo tiff 0.11.3 byte_order_u64().(bytes: &mut [u8]) {
639 for chunk in bytes.chunks_exact_mutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]chunks_exact_mut().(8) {
640 let n = u64::from_ne_bytesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u64]from_ne_bytes().(chunk.try_intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/TryInto#try_into().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().());
641 chunk.copy_from_slicerust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]copy_from_slice().(&n.to_le_bytesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u64]to_le_bytes().());
642 }
643 }
644
645 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
•646 #[ignore = "skipping, missing test data"]
647 fn bytes_cmyk_3c_8brust-analyzer cargo tiff 0.11.3 bytes_cmyk_3c_8b().() {
648 test_image_bytesrust-analyzer cargo tiff 0.11.3 test_image_bytes().(
649 "cmyk-3c-8b.tiff",
650 &[(ColorTyperust-analyzer cargo tiff 0.11.3 ColorType#::CMYKrust-analyzer cargo tiff 0.11.3 ColorType#CMYK#(8), 2935032230)],
651 |_| (),
652 );
653 }
654
655 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
•656 #[ignore = "skipping, missing test data"]
657 fn bytes_gray_16brust-analyzer cargo tiff 0.11.3 bytes_gray_16b().() {
658 test_image_bytesrust-analyzer cargo tiff 0.11.3 test_image_bytes().(
659 "minisblack-1c-16b.tiff",
660 &[(ColorTyperust-analyzer cargo tiff 0.11.3 ColorType#::Grayrust-analyzer cargo tiff 0.11.3 ColorType#Gray#(16), 3524597615)],
661 byte_order_u16rust-analyzer cargo tiff 0.11.3 byte_order_u16().,
662 );
663 }
664
665 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
•666 #[ignore = "skipping, missing test data"]
667 fn bytes_gray_32brust-analyzer cargo tiff 0.11.3 bytes_gray_32b().() {
668 test_image_bytesrust-analyzer cargo tiff 0.11.3 test_image_bytes().(
669 "gradient-1c-32b.tiff",
670 &[(ColorTyperust-analyzer cargo tiff 0.11.3 ColorType#::Grayrust-analyzer cargo tiff 0.11.3 ColorType#Gray#(32), 2257036530)],
671 byte_order_u32rust-analyzer cargo tiff 0.11.3 byte_order_u32().,
672 );
673 }
674
675 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
•676 #[ignore = "skipping, missing test data"]
677 fn bytes_gray_u64rust-analyzer cargo tiff 0.11.3 bytes_gray_u64().() {
678 test_image_bytesrust-analyzer cargo tiff 0.11.3 test_image_bytes().(
679 "gradient-1c-64b.tiff",
680 &[(ColorTyperust-analyzer cargo tiff 0.11.3 ColorType#::Grayrust-analyzer cargo tiff 0.11.3 ColorType#Gray#(64), 2156547113)],
681 byte_order_u64rust-analyzer cargo tiff 0.11.3 byte_order_u64().,
682 );
683 }
684
685 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
•686 #[ignore = "skipping, missing test data"]
687 fn bytes_gray_f32rust-analyzer cargo tiff 0.11.3 bytes_gray_f32().() {
688 test_image_bytesrust-analyzer cargo tiff 0.11.3 test_image_bytes().(
689 "gradient-1c-32b-float.tiff",
690 &[(ColorTyperust-analyzer cargo tiff 0.11.3 ColorType#::Grayrust-analyzer cargo tiff 0.11.3 ColorType#Gray#(32), 3232356730)],
691 byte_order_u32rust-analyzer cargo tiff 0.11.3 byte_order_u32().,
692 );
693 }
694
695 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
696 #[cfg(feature = "fax")]
•697 #[ignore = "skipping, missing test data"]
698 fn test_fax4rust-analyzer cargo tiff 0.11.3 test_fax4().() {
699 test_image_sum_u8rust-analyzer cargo tiff 0.11.3 test_image_sum_u8().("fax4.tiff", ColorTyperust-analyzer cargo tiff 0.11.3 ColorType#::Grayrust-analyzer cargo tiff 0.11.3 ColorType#Gray#(1), 7802706);
700 }
701
702 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
703 #[cfg(feature = "fax")]
•704 #[ignore = "skipping, missing test data"]
705 fn test_fax4_white_is_minrust-analyzer cargo tiff 0.11.3 test_fax4_white_is_min().() {
706 test_image_sum_u8rust-analyzer cargo tiff 0.11.3 test_image_sum_u8().("imagemagick_group4.tiff", ColorTyperust-analyzer cargo tiff 0.11.3 ColorType#::Grayrust-analyzer cargo tiff 0.11.3 ColorType#Gray#(1), 3742820);
707 }
708
709 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
•710 #[ignore = "skipping, missing test data"]
711 fn write_extra_bits_imagerust-analyzer cargo tiff 0.11.3 write_extra_bits_image().() {
712 use tiffrust-analyzer cargo tiff 0.11.3 crate/::{encoderrust-analyzer cargo tiff 0.11.3 encoder/, tagsrust-analyzer cargo tiff 0.11.3 tags/::ExtraSamplesrust-analyzer cargo tiff 0.11.3 tags/ExtraSamples#};
713
714 let path = PathBufrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/PathBuf#::fromrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[PathBuf][`From<&T>`]from().(TEST_IMAGE_DIRrust-analyzer cargo tiff 0.11.3 TEST_IMAGE_DIR.).joinrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[Path]join().("extra_bits_rgb_8b.tiff");
715 let img_file = Filerust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/File#::createrust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/impl#[File]create().(path).expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]expect().("Cannot find test image!");
716
717 let mut encoder = encoderrust-analyzer cargo tiff 0.11.3 encoder/::TiffEncoderrust-analyzer cargo tiff 0.11.3 encoder/TiffEncoder#::newrust-analyzer cargo tiff 0.11.3 encoder/impl#[`TiffEncoder<W>`]new().(img_file).expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]expect().("Cannot create encoder");
718 let mut img = encoder.new_imagerust-analyzer cargo tiff 0.11.3 encoder/impl#[`TiffEncoder<W, K>`]new_image().::<encoderrust-analyzer cargo tiff 0.11.3 encoder/::colortyperust-analyzer cargo tiff 0.11.3 encoder/colortype/::RGB8rust-analyzer cargo tiff 0.11.3 encoder/colortype/RGB8#>(8, 8).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
719
720 img.extra_samplesrust-analyzer cargo tiff 0.11.3 encoder/impl#[`ImageEncoder<'a, W, T, K>`]extra_samples().(&[ExtraSamplesrust-analyzer cargo tiff 0.11.3 tags/ExtraSamples#::Unspecifiedrust-analyzer cargo tiff 0.11.3 tags/ExtraSamples#Unspecified#]).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
721
722 // all pixels are supposed to be 0, the extra is 1
723 let data: [u8; 256] = corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::arrayrust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/::from_fnrust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/from_fn().(|i| (i as u8 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u8][`Rem<Self>`]rem().%rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u8][`Rem<Self>`]rem(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u8][`Rem<Self>`]rem().4).saturating_subrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u8]saturating_sub().(2));
724
725 img.write_datarust-analyzer cargo tiff 0.11.3 encoder/impl#[`ImageEncoder<'a, W, T, K>`]write_data().(&data)
726 .expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]expect().("correct amount of data to write");
727 }
728
729 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
•730 #[ignore = "skipping, missing test data"]
731 fn extra_bits_grayrust-analyzer cargo tiff 0.11.3 extra_bits_gray().() {
732 test_image_sum_u8rust-analyzer cargo tiff 0.11.3 test_image_sum_u8().(
733 "extra_bits_gray_8b.tiff",
734 ColorTyperust-analyzer cargo tiff 0.11.3 ColorType#::Multibandrust-analyzer cargo tiff 0.11.3 ColorType#Multiband# {
735 bit_depthrust-analyzer cargo tiff 0.11.3 ColorType#Multiband#bit_depth.: 8,
736 num_samplesrust-analyzer cargo tiff 0.11.3 ColorType#Multiband#num_samples.: 2,
737 },
738 64,
739 );
740 }
741
742 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
•743 #[ignore = "skipping, missing test data"]
744 fn extra_bits_rgbrust-analyzer cargo tiff 0.11.3 extra_bits_rgb().() {
745 test_image_sum_u8rust-analyzer cargo tiff 0.11.3 test_image_sum_u8().("extra_bits_rgb_8b.tiff", ColorTyperust-analyzer cargo tiff 0.11.3 ColorType#::RGBrust-analyzer cargo tiff 0.11.3 ColorType#RGB#(8), 0);
746 }