add CMYKA (#208)
This commit is contained in:
6 files changed
+23
No files matched your search
@@ -24,6 +24,7 @@ This table lists photometric interpretations and sample formats which are suppor
|
|||||||
| `RGBPalette` | | |
|
| `RGBPalette` | | |
|
||||||
| `Mask` | | |
|
| `Mask` | | |
|
||||||
| `CMYK` | CMYK(8\|16\|32\|64) | CMYK(32\|64) |
|
| `CMYK` | CMYK(8\|16\|32\|64) | CMYK(32\|64) |
|
||||||
|
| `CMYKA` | CMYKA(8) | |
|
||||||
| `YCbCr` | | |
|
| `YCbCr` | | |
|
||||||
| `CIELab` | | |
|
| `CIELab` | | |
|
||||||
|
|
||||||
|
|||||||
@@ -330,6 +330,7 @@ impl Image {
|
|||||||
},
|
},
|
||||||
PhotometricInterpretation::CMYK => match self.samples {
|
PhotometricInterpretation::CMYK => match self.samples {
|
||||||
4 => Ok(ColorType::CMYK(self.bits_per_sample)),
|
4 => Ok(ColorType::CMYK(self.bits_per_sample)),
|
||||||
|
5 => Ok(ColorType::CMYKA(self.bits_per_sample)),
|
||||||
_ => Err(TiffError::UnsupportedError(
|
_ => Err(TiffError::UnsupportedError(
|
||||||
TiffUnsupportedError::InterpretationWithBits(
|
TiffUnsupportedError::InterpretationWithBits(
|
||||||
self.photometric_interpretation,
|
self.photometric_interpretation,
|
||||||
@@ -567,6 +568,7 @@ impl Image {
|
|||||||
ColorType::RGB(n)
|
ColorType::RGB(n)
|
||||||
| ColorType::RGBA(n)
|
| ColorType::RGBA(n)
|
||||||
| ColorType::CMYK(n)
|
| ColorType::CMYK(n)
|
||||||
|
| ColorType::CMYKA(n)
|
||||||
| ColorType::YCbCr(n)
|
| ColorType::YCbCr(n)
|
||||||
| ColorType::Gray(n)
|
| ColorType::Gray(n)
|
||||||
| ColorType::Multiband {
|
| ColorType::Multiband {
|
||||||
|
|||||||
@@ -341,3 +341,13 @@ impl ColorType for YCbCr8 {
|
|||||||
|
|
||||||
integer_horizontal_predict!();
|
integer_horizontal_predict!();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub struct CMYKA8;
|
||||||
|
impl ColorType for CMYKA8 {
|
||||||
|
type Inner = u8;
|
||||||
|
const TIFF_VALUE: PhotometricInterpretation = PhotometricInterpretation::CMYK;
|
||||||
|
const BITS_PER_SAMPLE: &'static [u16] = &[8, 8, 8, 8, 8];
|
||||||
|
const SAMPLE_FORMAT: &'static [SampleFormat] = &[SampleFormat::Uint; 5];
|
||||||
|
|
||||||
|
integer_horizontal_predict!();
|
||||||
|
}
|
||||||
@@ -16,6 +16,7 @@ pub use self::error::{TiffError, TiffFormatError, TiffResult, TiffUnsupportedErr
|
|||||||
|
|
||||||
/// An enumeration over supported color types and their bit depths
|
/// An enumeration over supported color types and their bit depths
|
||||||
#[derive(Copy, PartialEq, Eq, Debug, Clone, Hash)]
|
#[derive(Copy, PartialEq, Eq, Debug, Clone, Hash)]
|
||||||
|
#[non_exhaustive]
|
||||||
pub enum ColorType {
|
pub enum ColorType {
|
||||||
/// Pixel is grayscale
|
/// Pixel is grayscale
|
||||||
Gray(u8),
|
Gray(u8),
|
||||||
@@ -35,6 +36,9 @@ pub enum ColorType {
|
|||||||
/// Pixel is CMYK
|
/// Pixel is CMYK
|
||||||
CMYK(u8),
|
CMYK(u8),
|
||||||
|
|
||||||
|
/// Pixel is CMYK with an alpha channel
|
||||||
|
CMYKA(u8),
|
||||||
|
|
||||||
/// Pixel is YCbCr
|
/// Pixel is YCbCr
|
||||||
YCbCr(u8),
|
YCbCr(u8),
|
||||||
|
|
||||||
@@ -50,6 +54,7 @@ impl ColorType {
|
|||||||
| ColorType::GrayA(b)
|
| ColorType::GrayA(b)
|
||||||
| ColorType::RGBA(b)
|
| ColorType::RGBA(b)
|
||||||
| ColorType::CMYK(b)
|
| ColorType::CMYK(b)
|
||||||
|
| ColorType::CMYKA(b)
|
||||||
| ColorType::YCbCr(b)
|
| ColorType::YCbCr(b)
|
||||||
| ColorType::Multiband { bit_depth: b, .. } => b,
|
| ColorType::Multiband { bit_depth: b, .. } => b,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -298,6 +298,11 @@ fn test_cmyk_u8_roundtrip() {
|
|||||||
test_u8_roundtrip::<colortype::CMYK8>("cmyk-3c-8b.tiff", ColorType::CMYK(8));
|
test_u8_roundtrip::<colortype::CMYK8>("cmyk-3c-8b.tiff", ColorType::CMYK(8));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_cmyka_u8_roundtrip() {
|
||||||
|
test_u8_roundtrip::<colortype::CMYKA8>("cmyk-4c-8b.tiff", ColorType::CMYKA(8));
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_gray_u16_roundtrip() {
|
fn test_gray_u16_roundtrip() {
|
||||||
test_u16_roundtrip::<colortype::Gray16>("minisblack-1c-16b.tiff", ColorType::Gray(16));
|
test_u16_roundtrip::<colortype::Gray16>("minisblack-1c-16b.tiff", ColorType::Gray(16));
|
||||||
|
|||||||
Binary file not shown.
Reference in new issue
Block a user