Support CMYK
This commit is contained in:
1 parent
08ff86bbf6
commit
6f0496b10a
2 files changed
+7
-2
No files matched your search
+4
-2
@@ -124,7 +124,7 @@ fn rev_hpredict(image: DecodingResult, size: (u32, u32), color_type: ColorType)
|
||||
let samples = match color_type {
|
||||
ColorType::Gray(8) | ColorType::Gray(16) => 1,
|
||||
ColorType::RGB(8) | ColorType::RGB(16) => 3,
|
||||
ColorType::RGBA(8) | ColorType::RGBA(16) => 4,
|
||||
ColorType::RGBA(8) | ColorType::RGBA(16) | ColorType::CMYK(8) => 4,
|
||||
_ => return Err(TiffError::UnsupportedError(format!(
|
||||
"Horizontal predictor for {:?} is unsupported.", color_type
|
||||
)))
|
||||
@@ -167,6 +167,7 @@ impl<R: Read + Seek> Decoder<R> {
|
||||
PhotometricInterpretation::RGB if self.bits_per_sample == [8, 8, 8] => Ok(ColorType::RGB(8)),
|
||||
PhotometricInterpretation::RGB if self.bits_per_sample == [16, 16, 16, 16] => Ok(ColorType::RGBA(16)),
|
||||
PhotometricInterpretation::RGB if self.bits_per_sample == [16, 16, 16] => Ok(ColorType::RGB(16)),
|
||||
PhotometricInterpretation::CMYK if self.bits_per_sample == [8, 8, 8, 8] => Ok(ColorType::CMYK(8)),
|
||||
PhotometricInterpretation::BlackIsZero | PhotometricInterpretation::WhiteIsZero
|
||||
if self.bits_per_sample.len() == 1 => Ok(ColorType::Gray(self.bits_per_sample[0])),
|
||||
|
||||
@@ -419,7 +420,8 @@ impl<R: Read + Seek> Decoder<R> {
|
||||
};
|
||||
Ok(match (color_type, buffer) {
|
||||
(ColorType:: RGB(8), DecodingBuffer::U8(ref mut buffer)) |
|
||||
(ColorType::RGBA(8), DecodingBuffer::U8(ref mut buffer)) => {
|
||||
(ColorType::RGBA(8), DecodingBuffer::U8(ref mut buffer)) |
|
||||
(ColorType::CMYK(8), DecodingBuffer::U8(ref mut buffer)) => {
|
||||
try!(reader.read(&mut buffer[..bytes]))
|
||||
}
|
||||
(ColorType::RGBA(16), DecodingBuffer::U16(ref mut buffer)) |
|
||||
|
||||
@@ -33,4 +33,7 @@ pub enum ColorType {
|
||||
|
||||
/// Pixel is RGB with an alpha channel
|
||||
RGBA(u8),
|
||||
|
||||
/// Pixel is CMYK
|
||||
CMYK(u8),
|
||||
}
|
||||
Reference in new issue
Block a user