-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #23 from birktj/encode
Tiff encoding
- Loading branch information
Showing
7 changed files
with
840 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,3 +19,6 @@ byteorder = "1.2" | |
lzw = "0.10" | ||
num-derive = "0.2" | ||
num-traits = "0.2" | ||
|
||
[dev-dependencies] | ||
tempfile = "3.0" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
use crate::decoder::PhotometricInterpretation; | ||
|
||
/// Trait for different colortypes that can be encoded. | ||
pub trait ColorType { | ||
/// The type of each sample of this colortype | ||
type Inner: super::TiffValue; | ||
/// The value of the tiff tag `PhotometricInterpretation` | ||
const TIFF_VALUE: PhotometricInterpretation; | ||
/// The value of the tiff tag `BitsPerSample` | ||
const BITS_PER_SAMPLE: &'static [u16]; | ||
} | ||
|
||
pub struct Gray8; | ||
impl ColorType for Gray8 { | ||
type Inner = u8; | ||
const TIFF_VALUE: PhotometricInterpretation = PhotometricInterpretation::BlackIsZero; | ||
const BITS_PER_SAMPLE: &'static [u16] = &[8]; | ||
} | ||
|
||
pub struct Gray16; | ||
impl ColorType for Gray16 { | ||
type Inner = u16; | ||
const TIFF_VALUE: PhotometricInterpretation = PhotometricInterpretation::BlackIsZero; | ||
const BITS_PER_SAMPLE: &'static [u16] = &[16]; | ||
} | ||
|
||
pub struct RGB8; | ||
impl ColorType for RGB8 { | ||
type Inner = u8; | ||
const TIFF_VALUE: PhotometricInterpretation = PhotometricInterpretation::RGB; | ||
const BITS_PER_SAMPLE: &'static [u16] = &[8, 8, 8]; | ||
} | ||
|
||
pub struct RGB16; | ||
impl ColorType for RGB16 { | ||
type Inner = u16; | ||
const TIFF_VALUE: PhotometricInterpretation = PhotometricInterpretation::RGB; | ||
const BITS_PER_SAMPLE: &'static [u16] = &[16, 16, 16]; | ||
} | ||
|
||
pub struct RGBA8; | ||
impl ColorType for RGBA8 { | ||
type Inner = u8; | ||
const TIFF_VALUE: PhotometricInterpretation = PhotometricInterpretation::RGB; | ||
const BITS_PER_SAMPLE: &'static [u16] = &[8, 8, 8, 8]; | ||
} | ||
|
||
pub struct RGBA16; | ||
impl ColorType for RGBA16 { | ||
type Inner = u16; | ||
const TIFF_VALUE: PhotometricInterpretation = PhotometricInterpretation::RGB; | ||
const BITS_PER_SAMPLE: &'static [u16] = &[16, 16, 16, 16]; | ||
} | ||
|
||
pub struct CMYK8; | ||
impl ColorType for CMYK8 { | ||
type Inner = u8; | ||
const TIFF_VALUE: PhotometricInterpretation = PhotometricInterpretation::CMYK; | ||
const BITS_PER_SAMPLE: &'static [u16] = &[8, 8, 8, 8]; | ||
} |
Oops, something went wrong.