Skip to main content

SampleLayout

Struct SampleLayout 

Source
#[non_exhaustive]
pub struct SampleLayout { /* private fields */ }
Expand description

Complete interleaved storage description for a single plane of pixels.

Implementations§

Source§

impl SampleLayout

Source

pub const RGB8: SampleLayout

Packed 8-bit RGB (3 B/px).

Source

pub const RGBA8: SampleLayout

Packed 8-bit RGBA (4 B/px).

Source

pub const BGR8: SampleLayout

Packed 8-bit BGR (3 B/px).

Source

pub const BGRA8: SampleLayout

Packed 8-bit BGRA (4 B/px).

Source

pub const RGBX8: SampleLayout

Packed 8-bit RGBx (4 B/px, 4th byte padding).

Source

pub const BGRX8: SampleLayout

Packed 8-bit BGRx (4 B/px, 4th byte padding).

Source

pub const GRAY8: SampleLayout

Packed 8-bit grayscale (1 B/px).

Source

pub const GRAYA8: SampleLayout

Packed 8-bit grayscale + alpha (2 B/px).

Source

pub const RGB16: SampleLayout

Packed 16-bit RGB (6 B/px).

Source

pub const RGBA16: SampleLayout

Packed 16-bit RGBA (8 B/px).

Source

pub const GRAY16: SampleLayout

Packed 16-bit grayscale (2 B/px).

Source

pub const GRAYA16: SampleLayout

Packed 16-bit grayscale + alpha (4 B/px).

Source

pub const RGBF16: SampleLayout

Packed f16 RGB (6 B/px).

Source

pub const RGBAF16: SampleLayout

Packed f16 RGBA (8 B/px).

Source

pub const GRAYF16: SampleLayout

Packed f16 grayscale (2 B/px).

Source

pub const GRAYAF16: SampleLayout

Packed f16 grayscale + alpha (4 B/px).

Source

pub const RGBF32: SampleLayout

Packed f32 RGB (12 B/px).

Source

pub const RGBAF32: SampleLayout

Packed f32 RGBA (16 B/px).

Source

pub const GRAYF32: SampleLayout

Packed f32 grayscale (4 B/px).

Source

pub const GRAYAF32: SampleLayout

Packed f32 grayscale + alpha (8 B/px).

Source

pub const XYZF32: SampleLayout

Packed f32 CIE XYZ (12 B/px).

Source

pub const XYZAF32: SampleLayout

Packed f32 CIE XYZ + alpha (16 B/px).

Source

pub const OKLABF32: SampleLayout

Packed f32 Oklab (12 B/px).

Source

pub const OKLABAF32: SampleLayout

Packed f32 Oklab + alpha (16 B/px).

Source

pub const CMYK8: SampleLayout

Packed 8-bit CMYK (4 B/px, 0 = no ink).

Source

pub const CMYK8_INVERTED: SampleLayout

Packed 8-bit inverted CMYK (4 B/px, 255 = no ink).

Source

pub const CMYKA8: SampleLayout

Packed 8-bit CMYK + alpha (5 B/px, 0 = no ink).

Source

pub const CMYKA8_INVERTED: SampleLayout

Packed 8-bit inverted CMYK + alpha (5 B/px, 255 = no ink).

Source

pub const CMYK16: SampleLayout

Packed 16-bit CMYK (8 B/px).

Source

pub const CMYKF32: SampleLayout

Packed f32 CMYK (16 B/px).

Source

pub const RGB565: SampleLayout

Packed 16-bit RGB565 bitfield word (2 B/px).

Source

pub const RGB10A2: SampleLayout

Packed 32-bit RGB10A2 bitfield word (4 B/px).

Source

pub const fn sample(self) -> SampleType

The sample of this layout.

Source

pub const fn order(self) -> ChannelOrder

The order of this layout.

Source

pub const fn packing(self) -> BitPacking

The packing of this layout.

Source

pub const fn new(sample: SampleType, order: ChannelOrder) -> SampleLayout

Construct a full-width interleaved sample layout.

§Panics

Panics if the order declares zero or more than 16 channels. Use try_new for a dynamically supplied channel order.

Source

pub const fn try_new( sample: SampleType, order: ChannelOrder, ) -> Result<SampleLayout, LayoutError>

Construct a full-width layout, checking the declared channel count.

Source

pub const fn try_with_packing( self, packing: BitPacking, ) -> Result<SampleLayout, LayoutError>

Attach bit packing compatible with the sample type and channel count.

Source

pub const fn channels(self) -> usize

Number of channels per pixel.

Source

pub const fn bytes_per_pixel(self) -> usize

Bytes occupied by one pixel in memory.

For BitPacking::Bitfields (such as RGB565), all channels fit inside a single storage word, so this equals self.sample.byte_size().

Source

pub const fn min_alignment(self) -> usize

Minimum byte alignment required for row starts and slice pointers.

Source

pub const fn validate(self) -> Result<(), LayoutError>

Validate that channel count and bit packing are well-formed.

Source

pub const fn aligned_stride( self, width: u32, align: RowAlign, ) -> Result<usize, LayoutError>

Compute the row byte stride for width pixels under align.

Trait Implementations§

Source§

impl Clone for SampleLayout

Source§

fn clone(&self) -> SampleLayout

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 SampleLayout

Source§

impl Debug for SampleLayout

Source§

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

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

impl Eq for SampleLayout

Source§

impl Hash for SampleLayout

Source§

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

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 SampleLayout

Source§

fn eq(&self, other: &SampleLayout) -> 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 SampleLayout

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.