diff --git a/src/decoder/mod.rs b/src/decoder/mod.rs index 0b6719e..933d6c1 100644 --- a/src/decoder/mod.rs +++ b/src/decoder/mod.rs @@ -295,8 +295,8 @@ where fn rev_hpredict(image: DecodingBuffer, size: (u32, u32), color_type: ColorType) -> TiffResult<()> { let samples = match color_type { ColorType::Gray(8) | ColorType::Gray(16) | ColorType::Gray(32) | ColorType::Gray(64) => 1, - ColorType::RGB(8) | ColorType::RGB(16) | ColorType::RGB(32) => 3, - ColorType::RGBA(8) | ColorType::RGBA(16) | ColorType::RGBA(32) | ColorType::CMYK(8) => 4, + ColorType::RGB(8) | ColorType::RGB(16) | ColorType::RGB(32) | ColorType::RGB(64) => 3, + ColorType::RGBA(8) | ColorType::RGBA(16) | ColorType::RGBA(32) | ColorType::RGBA(64) | ColorType::CMYK(8) => 4, _ => { return Err(TiffError::UnsupportedError( TiffUnsupportedError::HorizontalPredictor(color_type), @@ -370,6 +370,12 @@ impl Decoder { PhotometricInterpretation::RGB if self.bits_per_sample == [32, 32, 32] => { Ok(ColorType::RGB(32)) } + PhotometricInterpretation::RGB if self.bits_per_sample == [64, 64, 64, 64] => { + Ok(ColorType::RGBA(64)) + } + PhotometricInterpretation::RGB if self.bits_per_sample == [64, 64, 64] => { + Ok(ColorType::RGB(64)) + } PhotometricInterpretation::CMYK if self.bits_per_sample == [8, 8, 8, 8] => { Ok(ColorType::CMYK(8)) } @@ -720,6 +726,11 @@ impl Decoder { reader.read_u32_into(&mut buffer[..bytes / 4])?; bytes / 4 } + (ColorType::RGBA(64), DecodingBuffer::U64(ref mut buffer)) + | (ColorType::RGB(64), DecodingBuffer::U64(ref mut buffer)) => { + reader.read_u64_into(&mut buffer[..bytes / 8])?; + bytes / 8 + } (ColorType::Gray(64), DecodingBuffer::U64(ref mut buffer)) => { reader.read_u64_into(&mut buffer[..bytes / 8])?; if self.photometric_interpretation == PhotometricInterpretation::WhiteIsZero { diff --git a/tests/decode_images.rs b/tests/decode_images.rs index 04ca7ef..ae1e573 100644 --- a/tests/decode_images.rs +++ b/tests/decode_images.rs @@ -142,6 +142,25 @@ fn test_rgb_u32() { } } +#[test] +fn test_rgb_u64() { + let img_file = File::open("./tests/images/gradient-3c-64b.tiff").expect("Cannot find test image!"); + let mut decoder = Decoder::new(img_file).expect("Cannot create decoder"); + assert_eq!(decoder.colortype().unwrap(), ColorType::RGB(64)); + let img_res = decoder.read_image().unwrap(); + if let DecodingResult::U64(res) = img_res { + let mut res_sum: u64 = 0; + for x in res { + res_sum += x as u64; + } + + assert_eq!(res_sum, 2030834111716); + } + else { + panic!("Wrong bit depth") + } +} + #[test] fn test_string_tags() { // these files have null-terminated strings for their Software tag. One has extra bytes after diff --git a/tests/images/gradient-3c-64b.tiff b/tests/images/gradient-3c-64b.tiff new file mode 100644 index 0000000..0c5c4dc Binary files /dev/null and b/tests/images/gradient-3c-64b.tiff differ