#[non_exhaustive]#[repr(u8)]pub enum PixelFormat {
Show 22 variants
Rgb8 = 1,
Rgba8 = 2,
Rgb16 = 3,
Rgba16 = 4,
RgbF32 = 5,
RgbaF32 = 6,
Gray8 = 7,
Gray16 = 8,
GrayF32 = 9,
GrayA8 = 10,
GrayA16 = 11,
GrayAF32 = 12,
Bgra8 = 13,
Rgbx8 = 14,
Bgrx8 = 15,
OklabF32 = 16,
OklabaF32 = 17,
Cmyk8 = 18,
RgbF16 = 19,
RgbaF16 = 20,
GrayF16 = 21,
GrayAF16 = 22,
}Expand description
Physical pixel layout for match-based format dispatch.
Each variant encodes the channel type (U8/U16/F32) and layout (RGB/RGBA/
Gray/etc.) in one discriminant. Transfer function and alpha mode live on
PixelDescriptor, not here.
Use this enum when you need exhaustive match dispatch over known
pixel layouts.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Rgb8 = 1
Rgba8 = 2
Rgb16 = 3
Rgba16 = 4
RgbF32 = 5
RgbaF32 = 6
Gray8 = 7
Gray16 = 8
GrayF32 = 9
GrayA8 = 10
GrayA16 = 11
GrayAF32 = 12
Bgra8 = 13
Rgbx8 = 14
Bgrx8 = 15
OklabF32 = 16
OklabaF32 = 17
Cmyk8 = 18
8-bit CMYK (4 bytes per pixel, no transfer function).
RgbF16 = 19
f16 (IEEE 754 half-precision) RGB.
RgbaF16 = 20
f16 (IEEE 754 half-precision) RGBA.
GrayF16 = 21
f16 (IEEE 754 half-precision) grayscale.
GrayAF16 = 22
f16 (IEEE 754 half-precision) grayscale with alpha.
Implementations§
Source§impl PixelFormat
impl PixelFormat
Sourcepub const fn channel_type(self) -> ChannelType
pub const fn channel_type(self) -> ChannelType
Channel storage type.
Sourcepub const fn layout(self) -> ChannelLayout
pub const fn layout(self) -> ChannelLayout
Channel layout.
Sourcepub const fn color_model(self) -> ColorModel
pub const fn color_model(self) -> ColorModel
Color model (what the channels represent).
Sourcepub const fn byte_order(self) -> ByteOrder
pub const fn byte_order(self) -> ByteOrder
Byte order (Native or BGR).
Sourcepub const fn bytes_per_pixel(self) -> usize
pub const fn bytes_per_pixel(self) -> usize
Bytes per pixel.
Sourcepub const fn has_alpha_bytes(self) -> bool
pub const fn has_alpha_bytes(self) -> bool
Whether this format has alpha or padding bytes (4th channel).
Sourcepub const fn is_grayscale(self) -> bool
pub const fn is_grayscale(self) -> bool
Whether this format is grayscale.
Sourcepub const fn default_alpha(self) -> Option<AlphaMode>
pub const fn default_alpha(self) -> Option<AlphaMode>
Default alpha mode for this format.
- Formats with no alpha bytes →
None - Formats with padding (Rgbx8, Bgrx8) →
Some(AlphaMode::Undefined) - Formats with alpha →
Some(AlphaMode::Straight)
Sourcepub const fn from_parts(
channel_type: ChannelType,
layout: ChannelLayout,
alpha: Option<AlphaMode>,
) -> Option<PixelFormat>
pub const fn from_parts( channel_type: ChannelType, layout: ChannelLayout, alpha: Option<AlphaMode>, ) -> Option<PixelFormat>
Resolve a format from channel type, layout, and alpha presence.
Returns None for combinations that have no PixelFormat variant
(e.g. (U16, Bgra, _)).
Sourcepub const fn descriptor(self) -> PixelDescriptor
pub const fn descriptor(self) -> PixelDescriptor
Base descriptor with Unknown transfer and BT.709 primaries.
Trait Implementations§
Source§impl Clone for PixelFormat
impl Clone for PixelFormat
Source§fn clone(&self) -> PixelFormat
fn clone(&self) -> PixelFormat
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for PixelFormat
Source§impl Debug for PixelFormat
impl Debug for PixelFormat
Source§impl Display for PixelFormat
impl Display for PixelFormat
impl Eq for PixelFormat
Source§impl Hash for PixelFormat
impl Hash for PixelFormat
Source§impl PartialEq for PixelFormat
impl PartialEq for PixelFormat
Source§fn eq(&self, other: &PixelFormat) -> bool
fn eq(&self, other: &PixelFormat) -> bool
self and other values to be equal, and is used by ==.