#[non_exhaustive]pub enum PixelFormat {
Gray8,
Gray16,
GrayA8,
Rgb8,
Rgba8,
Rgb16,
Rgba16,
RgbF32,
RgbaF32,
}Expand description
An interleaved pixel format: a ChannelLayout over a SampleKind.
The v1 set is exactly the formats listed in SPEC §Pixel formats. Samples
are interleaved (RGBRGB…, not planar) and, for U16, stored in native
endianness in memory — codecs convert at their own boundary.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
Gray8
8-bit grayscale.
Gray16
16-bit grayscale.
GrayA8
8-bit grayscale with alpha.
Rgb8
8-bit RGB.
Rgba8
8-bit RGBA.
Rgb16
16-bit RGB.
Rgba16
16-bit RGBA.
RgbF32
32-bit float RGB.
RgbaF32
32-bit float RGBA.
Implementations§
Source§impl PixelFormat
impl PixelFormat
Sourcepub const fn layout(self) -> ChannelLayout
pub const fn layout(self) -> ChannelLayout
The channel layout of this format.
Sourcepub const fn from_parts(layout: ChannelLayout, kind: SampleKind) -> Option<Self>
pub const fn from_parts(layout: ChannelLayout, kind: SampleKind) -> Option<Self>
The format with layout channels of kind samples, if v1 has one
(there is no grey float, nor 16-bit grey with alpha).
Sourcepub const fn sample_kind(self) -> SampleKind
pub const fn sample_kind(self) -> SampleKind
The sample type of this format.
Sourcepub const fn bytes_per_pixel(self) -> usize
pub const fn bytes_per_pixel(self) -> usize
Size of one pixel in bytes.
This is exact: v1 formats are byte-aligned and interleaved, so there is no sub-byte packing to account for.
Trait Implementations§
Source§impl Clone for PixelFormat
impl Clone for PixelFormat
impl 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
impl StructuralPartialEq for PixelFormat
Auto Trait Implementations§
impl Freeze for PixelFormat
impl RefUnwindSafe for PixelFormat
impl Send for PixelFormat
impl Sync for PixelFormat
impl Unpin for PixelFormat
impl UnsafeUnpin for PixelFormat
impl UnwindSafe for PixelFormat
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more