#[non_exhaustive]#[repr(u8)]pub enum PixelFormat {
Show 17 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,
}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
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<Self>
pub const fn from_parts( channel_type: ChannelType, layout: ChannelLayout, alpha: Option<AlphaMode>, ) -> Option<Self>
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 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more