Enum ExtendedColorType
#[non_exhaustive]
pub enum ExtendedColorType
An enumeration of color types encountered in image formats.
This is not exhaustive over all existing image formats but should be granular enough to allow round tripping of decoding and encoding as much as possible. The variants will be extended as necessary to enable this.
Another purpose is to advise users of a rough estimate of the accuracy and effort of the decoding from and encoding to such an image format.
Variants
-
A8 Pixel is 8-bit alpha
-
L1 Pixel is 1-bit luminance
-
La1 Pixel is 1-bit luminance with an alpha channel
-
Rgb1 Pixel contains 1-bit R, G and B channels
-
Rgba1 Pixel is 1-bit RGB with an alpha channel
-
L2 Pixel is 2-bit luminance
-
La2 Pixel is 2-bit luminance with an alpha channel
-
Rgb2 Pixel contains 2-bit R, G and B channels
-
Rgba2 Pixel is 2-bit RGB with an alpha channel
-
L4 Pixel is 4-bit luminance
-
La4 Pixel is 4-bit luminance with an alpha channel
-
Rgb4 Pixel contains 4-bit R, G and B channels
-
Rgba4 Pixel is 4-bit RGB with an alpha channel
-
Rgb5x1 Pixel contains 5-bit R, G and B channels packed into 2 bytes
-
L8 Pixel is 8-bit luminance
-
La8 Pixel is 8-bit luminance with an alpha channel
-
Rgb8 Pixel contains 8-bit R, G and B channels
-
Rgba8 Pixel is 8-bit RGB with an alpha channel
-
L16 Pixel is 16-bit luminance
-
La16 Pixel is 16-bit luminance with an alpha channel
-
Rgb16 Pixel contains 16-bit R, G and B channels
-
Rgba16 Pixel is 16-bit RGB with an alpha channel
-
Bgr8 Pixel contains 8-bit B, G and R channels
-
Bgra8 Pixel is 8-bit BGR with an alpha channel
-
Rgb32F Pixel is 32-bit float RGB
-
Rgba32F Pixel is 32-bit float RGBA
-
Cmyk8 Pixel is 8-bit CMYK
-
Cmyk16 Pixel is 16-bit CMYK
-
Unknown(u8) Pixel is of unknown color type with the specified bits per pixel. This can apply to pixels which are associated with an external palette. In that case, the pixel value is an index into the palette.
Implementations
impl ExtendedColorType
fn channel_count(self) -> u8Get the number of channels for colors of this type.
Note that the
Unknownvariant returns a value of1since pixels can only be treated as an opaque datum by the library.fn bits_per_pixel(&self) -> u16Returns the number of bits per pixel for this color type.
fn color_type(&self) -> Option<ColorType>Returns the ColorType that is equivalent to this ExtendedColorType.
Example
use image::{ColorType, ExtendedColorType}; assert_eq!(Some(ColorType::L8), ExtendedColorType::L8.color_type()); assert_eq!(None, ExtendedColorType::L1.color_type());The method is equivalent to converting via the
TryFrom/TryIntotraits except for the error path. Choose the more ergonomic option in your usage.use image::{ColorType, ExtendedColorType, ImageError}; fn handle_errors() -> Result<(), ImageError> { let color: ColorType = ExtendedColorType::L8.try_into()?; assert_eq!(color, ColorType::L8); # Ok(()) }
Trait Implementations
impl Clone for ExtendedColorType
fn clone(&self) -> Self
impl Copy for ExtendedColorType
impl Debug for ExtendedColorType
fn fmt(&self, f: &mut Formatter<'_>) -> Result
impl Eq for ExtendedColorType
impl From<ColorType> for ExtendedColorType
fn from(c: ColorType) -> Self
impl Hash for ExtendedColorType
fn hash<__H: Hasher>(&self, state: &mut __H)
impl PartialEq for ExtendedColorType
fn eq(&self, other: &Self) -> bool