1 use decoder::PhotometricInterpretation; 2 3 /// Trait for different colortypes that can be encoded. 4 pub trait ColorType { 5 /// The type of each sample of this colortype 6 type Inner: super::TiffValue; 7 /// The value of the tiff tag `PhotometricInterpretation` 8 const TIFF_VALUE: PhotometricInterpretation; 9 /// The value of the tiff tag `BitsPerSample` 10 const BITS_PER_SAMPLE: &'static [u16]; 11 } 12 13 pub struct Gray8; 14 impl ColorType for Gray8 { 15 type Inner = u8; 16 const TIFF_VALUE: PhotometricInterpretation = PhotometricInterpretation::BlackIsZero; 17 const BITS_PER_SAMPLE: &'static [u16] = &[8]; 18 } 19 20 pub struct Gray16; 21 impl ColorType for Gray16 { 22 type Inner = u16; 23 const TIFF_VALUE: PhotometricInterpretation = PhotometricInterpretation::BlackIsZero; 24 const BITS_PER_SAMPLE: &'static [u16] = &[16]; 25 } 26 27 pub struct RGB8; 28 impl ColorType for RGB8 { 29 type Inner = u8; 30 const TIFF_VALUE: PhotometricInterpretation = PhotometricInterpretation::RGB; 31 const BITS_PER_SAMPLE: &'static [u16] = &[8, 8, 8]; 32 } 33 34 pub struct RGB16; 35 impl ColorType for RGB16 { 36 type Inner = u16; 37 const TIFF_VALUE: PhotometricInterpretation = PhotometricInterpretation::RGB; 38 const BITS_PER_SAMPLE: &'static [u16] = &[16, 16, 16]; 39 } 40 41 pub struct RGBA8; 42 impl ColorType for RGBA8 { 43 type Inner = u8; 44 const TIFF_VALUE: PhotometricInterpretation = PhotometricInterpretation::RGB; 45 const BITS_PER_SAMPLE: &'static [u16] = &[8, 8, 8, 8]; 46 } 47 48 pub struct RGBA16; 49 impl ColorType for RGBA16 { 50 type Inner = u16; 51 const TIFF_VALUE: PhotometricInterpretation = PhotometricInterpretation::RGB; 52 const BITS_PER_SAMPLE: &'static [u16] = &[16, 16, 16, 16]; 53 } 54 55 pub struct CMYK8; 56 impl ColorType for CMYK8 { 57 type Inner = u8; 58 const TIFF_VALUE: PhotometricInterpretation = PhotometricInterpretation::CMYK; 59 const BITS_PER_SAMPLE: &'static [u16] = &[8, 8, 8, 8]; 60 } 61