Merge pull request #5 from 335g/cmyk

CMYK support
This commit is contained in:
Yoshiki Kudo authored and GitHub committed 2018-07-06 18:44:07 +09:00
commit 123cc10379
2 files changed
+7 -2

No files matched your search

+4 -2
View File
@@ -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)) |
+3
View File
@@ -33,4 +33,7 @@ pub enum ColorType {
/// Pixel is RGB with an alpha channel
RGBA(u8),
/// Pixel is CMYK
CMYK(u8),
}