Debian Codegraph @

tests/decode_geotiff_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/::{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/::tagsrust-analyzer cargo tiff 0.11.3 tags/::Tagrust-analyzer cargo tiff 0.11.3 tags/Tag#;
5 use tiffrust-analyzer cargo tiff 0.11.3 crate/::ColorTyperust-analyzer cargo tiff 0.11.3 ColorType#;
6
7 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#;
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/geotiff";
11
12 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
•13 #[ignore = "skipping, missing test data"]
14 fn test_geo_tiffrust-analyzer cargo tiff 0.11.3 test_geo_tiff().() {
15 let filenames = ["geo-5b.tif"];
16 for filename in filenames.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().() {
17 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().(filename);
18 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!");
19 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");
20 decoder = decoder.with_limitsrust-analyzer cargo tiff 0.11.3 decoder/impl#[`Decoder<R>`]with_limits().(tiffrust-analyzer cargo tiff 0.11.3 crate/::decoderrust-analyzer cargo tiff 0.11.3 decoder/::Limitsrust-analyzer cargo tiff 0.11.3 decoder/Limits#::unlimitedrust-analyzer cargo tiff 0.11.3 decoder/impl#[Limits]unlimited().());
21
22 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
23 decoder.dimensionsrust-analyzer cargo tiff 0.11.3 decoder/impl#[`Decoder<R>`]dimensions().().expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]expect().("Cannot get dimensions"),
24 (10, 10)
25 );
26 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
27 decoder.colortyperust-analyzer cargo tiff 0.11.3 decoder/impl#[`Decoder<R>`]colortype().().expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]expect().("Cannot get colortype"),
28 ColorTyperust-analyzer cargo tiff 0.11.3 ColorType#::Multibandrust-analyzer cargo tiff 0.11.3 ColorType#Multiband# {
29 bit_depthrust-analyzer cargo tiff 0.11.3 ColorType#Multiband#bit_depth.: 16,
30 num_samplesrust-analyzer cargo tiff 0.11.3 ColorType#Multiband#num_samples.: 5
31 }
32 );
33 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
34 decoder
35 .get_tag_u64rust-analyzer cargo tiff 0.11.3 decoder/impl#[`Decoder<R>`]get_tag_u64().(Tagrust-analyzer cargo tiff 0.11.3 tags/Tag#::StripOffsetsrust-analyzer cargo tiff 0.11.3 tags/Tag#StripOffsets#)
36 .expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]expect().("Cannot get StripOffsets"),
37 418
38 );
39 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
40 decoder
41 .get_tag_u64rust-analyzer cargo tiff 0.11.3 decoder/impl#[`Decoder<R>`]get_tag_u64().(Tagrust-analyzer cargo tiff 0.11.3 tags/Tag#::RowsPerStriprust-analyzer cargo tiff 0.11.3 tags/Tag#RowsPerStrip#)
42 .expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]expect().("Cannot get RowsPerStrip"),
43 10
44 );
45 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
46 decoder
47 .get_tag_u64rust-analyzer cargo tiff 0.11.3 decoder/impl#[`Decoder<R>`]get_tag_u64().(Tagrust-analyzer cargo tiff 0.11.3 tags/Tag#::StripByteCountsrust-analyzer cargo tiff 0.11.3 tags/Tag#StripByteCounts#)
48 .expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]expect().("Cannot get StripByteCounts"),
49 1000
50 );
51 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
52 decoder
53 .get_tagrust-analyzer cargo tiff 0.11.3 decoder/impl#[`Decoder<R>`]get_tag().(Tagrust-analyzer cargo tiff 0.11.3 tags/Tag#::ModelPixelScaleTagrust-analyzer cargo tiff 0.11.3 tags/Tag#ModelPixelScaleTag#)
54 .expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]expect().("Cannot get pixel scale")
55 .into_f64_vecrust-analyzer cargo tiff 0.11.3 decoder/ifd/impl#[Value]into_f64_vec().()
56 .expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]expect().("Cannot get pixel scale"),
57 vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![60.0, 60.0, 0.0]
58 );
59 let DecodingResultrust-analyzer cargo tiff 0.11.3 decoder/DecodingResult#::I16rust-analyzer cargo tiff 0.11.3 decoder/DecodingResult#I16#(data) = 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().() else {
60 panicrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/panic!!("Cannot read band data")
61 };
62 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(data.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().(), 500);
63 }
64 }
65
66 #[cfg(feature = "webp")]
67 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
•68 #[ignore = "skipping, missing test data"]
69 fn test_webp_tiffrust-analyzer cargo tiff 0.11.3 test_webp_tiff().() {
70 let filenames = ["usda_naip_256_webp_z3.tif"];
71 let mut buffer = DecodingResultrust-analyzer cargo tiff 0.11.3 decoder/DecodingResult#::U8rust-analyzer cargo tiff 0.11.3 decoder/DecodingResult#U8#(vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![]);
72
73 for filename in filenames.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().() {
74 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().(filename);
75 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!");
76 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");
77
78 loop {
79 decoder.read_image_to_bufferrust-analyzer cargo tiff 0.11.3 decoder/impl#[`Decoder<R>`]read_image_to_buffer().(&mut buffer).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
80
81 if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().decoder.more_imagesrust-analyzer cargo tiff 0.11.3 decoder/impl#[`Decoder<R>`]more_images().() {
82 break;
83 }
84
85 decoder.next_imagerust-analyzer cargo tiff 0.11.3 decoder/impl#[`Decoder<R>`]next_image().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
86 }
87 }
88 }