From be0619d6a141c6f6c04cac49a2b67704296caee6 Mon Sep 17 00:00:00 2001 From: Jonathan Behrens Date: Sun, 20 Jun 2021 14:27:08 -0400 Subject: [PATCH] Support encoding signed integer formats --- src/encoder/colortype.rs | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/src/encoder/colortype.rs b/src/encoder/colortype.rs index 4813ba2..f6c775a 100644 --- a/src/encoder/colortype.rs +++ b/src/encoder/colortype.rs @@ -20,6 +20,14 @@ impl ColorType for Gray8 { const SAMPLE_FORMAT: &'static [SampleFormat] = &[SampleFormat::Uint]; } +pub struct GrayI8; +impl ColorType for GrayI8 { + type Inner = i8; + const TIFF_VALUE: PhotometricInterpretation = PhotometricInterpretation::BlackIsZero; + const BITS_PER_SAMPLE: &'static [u16] = &[8]; + const SAMPLE_FORMAT: &'static [SampleFormat] = &[SampleFormat::Int]; +} + pub struct Gray16; impl ColorType for Gray16 { type Inner = u16; @@ -28,6 +36,14 @@ impl ColorType for Gray16 { const SAMPLE_FORMAT: &'static [SampleFormat] = &[SampleFormat::Uint]; } +pub struct GrayI16; +impl ColorType for GrayI16 { + type Inner = i16; + const TIFF_VALUE: PhotometricInterpretation = PhotometricInterpretation::BlackIsZero; + const BITS_PER_SAMPLE: &'static [u16] = &[16]; + const SAMPLE_FORMAT: &'static [SampleFormat] = &[SampleFormat::Int]; +} + pub struct Gray32; impl ColorType for Gray32 { type Inner = u32; @@ -36,6 +52,14 @@ impl ColorType for Gray32 { const SAMPLE_FORMAT: &'static [SampleFormat] = &[SampleFormat::Uint]; } +pub struct GrayI32; +impl ColorType for GrayI32 { + type Inner = i32; + const TIFF_VALUE: PhotometricInterpretation = PhotometricInterpretation::BlackIsZero; + const BITS_PER_SAMPLE: &'static [u16] = &[32]; + const SAMPLE_FORMAT: &'static [SampleFormat] = &[SampleFormat::Int]; +} + pub struct Gray32Float; impl ColorType for Gray32Float { type Inner = f32; @@ -52,6 +76,14 @@ impl ColorType for Gray64 { const SAMPLE_FORMAT: &'static [SampleFormat] = &[SampleFormat::Uint]; } +pub struct GrayI64; +impl ColorType for GrayI64 { + type Inner = i64; + const TIFF_VALUE: PhotometricInterpretation = PhotometricInterpretation::BlackIsZero; + const BITS_PER_SAMPLE: &'static [u16] = &[64]; + const SAMPLE_FORMAT: &'static [SampleFormat] = &[SampleFormat::Int]; +} + pub struct Gray64Float; impl ColorType for Gray64Float { type Inner = f64;