tiff/lib.rs
1//! Decoding and Encoding of TIFF Images
2//!
3//! TIFF (Tagged Image File Format) is a versatile image format that supports
4//! lossless and lossy compression.
5//!
6//! # Related Links
7//! * <https://web.archive.org/web/20210108073850/https://www.adobe.io/open/standards/TIFF.html> - The TIFF specification
8
9mod bytecast;
10pub mod decoder;
11mod directory;
12pub mod encoder;
13mod error;
14pub mod tags;
15
16pub use self::directory::Directory;
17pub use self::error::{TiffError, TiffFormatError, TiffResult, TiffUnsupportedError, UsageError};
18
19/// An enumeration over supported color types and their bit depths
20#[derive(Copy, PartialEq, Eq, Debug, Clone, Hash)]
21#[non_exhaustive]
22pub enum ColorType {
23 /// Pixel is grayscale
24 Gray(u8),
25
26 /// Pixel contains R, G and B channels
27 RGB(u8),
28
29 /// Pixel is an index into a color palette
30 Palette(u8),
31
32 /// Pixel is grayscale with an alpha channel
33 GrayA(u8),
34
35 /// Pixel is RGB with an alpha channel
36 RGBA(u8),
37
38 /// Pixel is CMYK
39 CMYK(u8),
40
41 /// Pixel is CMYK with an alpha channel
42 CMYKA(u8),
43
44 /// Pixel is YCbCr
45 YCbCr(u8),
46
47 /// Pixel has multiple bands/channels
48 Multiband { bit_depth: u8, num_samples: u16 },
49}
50impl ColorType {
51 fn bit_depth(&self) -> u8 {
52 match *self {
53 ColorType::Gray(b)
54 | ColorType::RGB(b)
55 | ColorType::Palette(b)
56 | ColorType::GrayA(b)
57 | ColorType::RGBA(b)
58 | ColorType::CMYK(b)
59 | ColorType::CMYKA(b)
60 | ColorType::YCbCr(b)
61 | ColorType::Multiband { bit_depth: b, .. } => b,
62 }
63 }
64}