Coverage Report

Created: 2025-10-12 08:06

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/rust/registry/src/index.crates.io-1949cf8c6b5b557f/tiff-0.10.3/src/lib.rs
Line
Count
Source
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
9
mod bytecast;
10
pub mod decoder;
11
mod directory;
12
pub mod encoder;
13
mod error;
14
pub mod tags;
15
16
pub use self::directory::Directory;
17
pub 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]
22
pub 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
}
50
impl ColorType {
51
3.00M
    fn bit_depth(&self) -> u8 {
52
3.00M
        match *self {
53
2.99M
            ColorType::Gray(b)
54
11.3k
            | ColorType::RGB(b)
55
0
            | ColorType::Palette(b)
56
0
            | ColorType::GrayA(b)
57
454
            | ColorType::RGBA(b)
58
2.04k
            | ColorType::CMYK(b)
59
0
            | ColorType::CMYKA(b)
60
0
            | ColorType::YCbCr(b)
61
3.00M
            | ColorType::Multiband { bit_depth: b, .. } => b,
62
        }
63
3.00M
    }
64
}