Skip to main content

PixelFormat

Enum PixelFormat 

Source
#[non_exhaustive]
#[repr(u32)]
pub enum PixelFormat { Gray8 = 0, Bilevel = 1, Indexed8 = 2, Rgb8 = 3, Rgba8 = 4, Cmyk8 = 5, GrayAlpha8 = 6, Gray16 = 7, Rgb16 = 8, Rgba16 = 9, GrayAlpha16 = 10, }
Expand description

Runtime tag for the closed set of Pixel marker types — one variant per marker.

The FFI/dispatch mirror of the compile-time Pixel matrix (issue #242): where the type system selects a codec impl through the marker type, a boundary that only has runtime information (a C caller, a plugin registry) selects the same layout by tag and dispatches to the monomorphized impl. PixelFormat::ALL enumerates the matrix for tooling that generates such dispatch.

Discriminants are explicit and permanent — they are C ABI values; new variants append.

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 = 0

Tag for Gray8.

§

Bilevel = 1

Tag for Bilevel.

§

Indexed8 = 2

Tag for Indexed8.

§

Rgb8 = 3

Tag for Rgb8.

§

Rgba8 = 4

Tag for Rgba8.

§

Cmyk8 = 5

Tag for Cmyk8.

§

GrayAlpha8 = 6

Tag for GrayAlpha8.

§

Gray16 = 7

Tag for Gray16.

§

Rgb16 = 8

Tag for Rgb16.

§

Rgba16 = 9

Tag for Rgba16.

§

GrayAlpha16 = 10

Tag for GrayAlpha16.

Implementations§

Source§

impl PixelFormat

Source

pub const ALL: [PixelFormat; 11]

Every pixel format, in discriminant order — the full codec × layout monomorphization matrix for tooling that enumerates it (each entry is some marker’s Pixel::FORMAT).

Source

pub const fn channels(self) -> usize

Samples per pixel; the runtime mirror of Pixel::CHANNELS.

Source

pub const fn color_model(self) -> ColorModel

The colour interpretation of the samples; the runtime mirror of Pixel::MODEL.

Source

pub const fn bytes_per_sample(self) -> usize

Bytes per sample of the storage primitive (1 for u8 layouts, 2 for u16); the runtime mirror of size_of::<Pixel::Sample>().

Source

pub const fn bytes_per_pixel(self) -> usize

Bytes one pixel occupies in an interleaved buffer; the runtime mirror of Pixel::BYTES_PER_PIXEL.

Trait Implementations§

Source§

impl Clone for PixelFormat

Source§

fn clone(&self) -> PixelFormat

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for PixelFormat

Source§

impl Debug for PixelFormat

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for PixelFormat

Source§

impl Hash for PixelFormat

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for PixelFormat

Source§

fn eq(&self, other: &PixelFormat) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for PixelFormat

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.