Support 32-bit rgb and rgba decoding

This commit is contained in:
Andrew Champion committed 2019-12-10 20:18:51 +00:00
1 parent fca4e1f88a
commit 1f92c562bc
3 files changed
+32 -2

No files matched your search

+13 -2
View File
@@ -273,8 +273,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) => 1,
ColorType::RGB(8) | ColorType::RGB(16) => 3,
ColorType::RGBA(8) | ColorType::RGBA(16) | ColorType::CMYK(8) => 4,
ColorType::RGB(8) | ColorType::RGB(16) | ColorType::RGB(32) => 3,
ColorType::RGBA(8) | ColorType::RGBA(16) | ColorType::RGBA(32) | ColorType::CMYK(8) => 4,
_ => {
return Err(TiffError::UnsupportedError(
TiffUnsupportedError::HorizontalPredictor(color_type),
@@ -339,6 +339,12 @@ impl<R: Read + Seek> Decoder<R> {
PhotometricInterpretation::RGB if self.bits_per_sample == [16, 16, 16] => {
Ok(ColorType::RGB(16))
}
PhotometricInterpretation::RGB if self.bits_per_sample == [32, 32, 32, 32] => {
Ok(ColorType::RGBA(32))
}
PhotometricInterpretation::RGB if self.bits_per_sample == [32, 32, 32] => {
Ok(ColorType::RGB(32))
}
PhotometricInterpretation::CMYK if self.bits_per_sample == [8, 8, 8, 8] => {
Ok(ColorType::CMYK(8))
}
@@ -684,6 +690,11 @@ impl<R: Read + Seek> Decoder<R> {
reader.read_u16_into(&mut buffer[..bytes / 2])?;
bytes / 2
}
(ColorType::RGBA(32), DecodingBuffer::U32(ref mut buffer))
| (ColorType::RGB(32), DecodingBuffer::U32(ref mut buffer)) => {
reader.read_u32_into(&mut buffer[..bytes / 4])?;
bytes / 4
}
(ColorType::Gray(32), DecodingBuffer::U32(ref mut buffer)) => {
reader.read_u32_into(&mut buffer[..bytes / 4])?;
if self.photometric_interpretation == PhotometricInterpretation::WhiteIsZero {