Skip to main content

PlaneLayout

Enum PlaneLayout 

Source
#[non_exhaustive]
pub enum PlaneLayout { Interleaved { channels: u8, }, Planar { planes: Vec<PlaneDescriptor>, relationship: PlaneRelationship, }, }
Expand description

Complete layout of a multi-plane image.

Separates the metadata (how many planes, what they represent, their subsampling) from any pixel buffers. Every consumer that needs to know about planar organization works with PlaneLayout; only code that allocates or reads pixels needs actual buffers.

§Examples

use zenpixels::{PlaneLayout, ChannelType, PlaneSemantic};

let layout = PlaneLayout::ycbcr_420(ChannelType::U8);
assert!(layout.is_planar());
assert!(layout.is_ycbcr());
assert!(layout.has_subsampling());
assert_eq!(layout.plane_count(), 3);

// Check plane semantics
let planes = layout.planes();
assert_eq!(planes[0].semantic, PlaneSemantic::Luma);
assert_eq!(planes[1].semantic, PlaneSemantic::ChromaCb);
assert!(!planes[0].is_subsampled());
assert!(planes[1].is_subsampled());

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.
§

Interleaved

Interleaved pixel data (channels packed per-pixel).

Fields

§channels: u8

Number of channels per pixel (e.g., 3 for RGB, 4 for RGBA).

§

Planar

Planar pixel data (one buffer per plane).

Fields

§planes: Vec<PlaneDescriptor>

Descriptor for each plane.

§relationship: PlaneRelationship

How the planes relate to each other.

Implementations§

Source§

impl PlaneLayout

Source

pub fn ycbcr_444(ct: ChannelType) -> PlaneLayout

YCbCr 4:4:4 (no subsampling).

Source

pub fn ycbcr_444_matrix(ct: ChannelType, matrix: YuvMatrix) -> PlaneLayout

YCbCr 4:4:4 with a specific matrix.

Source

pub fn ycbcr_422(ct: ChannelType) -> PlaneLayout

YCbCr 4:2:2 (horizontal half chroma).

Source

pub fn ycbcr_420(ct: ChannelType) -> PlaneLayout

YCbCr 4:2:0 (half chroma in both axes).

Source

pub fn rgb(ct: ChannelType) -> PlaneLayout

Planar RGB (3 independent planes, no subsampling).

Source

pub fn rgba(ct: ChannelType) -> PlaneLayout

Planar RGBA (4 independent planes, no subsampling).

Source

pub fn oklab(ct: ChannelType) -> PlaneLayout

Oklab (L/a/b, 3 planes, no subsampling).

Source

pub fn oklab_alpha(ct: ChannelType) -> PlaneLayout

Oklab with alpha (L/a/b/A, 4 planes, no subsampling).

Source

pub fn gray(ct: ChannelType) -> PlaneLayout

Grayscale (single plane, no subsampling).

Source

pub fn plane_count(&self) -> usize

Number of planes (or interleaved channels).

Source

pub fn planes(&self) -> &[PlaneDescriptor]

Plane descriptors. Empty slice for interleaved layout.

Source

pub fn luma_plane_index(&self) -> Option<usize>

Index of the luma/lightness plane, if any.

Source

pub fn has_subsampling(&self) -> bool

Whether any plane is subsampled.

Source

pub fn is_ycbcr(&self) -> bool

Whether this is a YCbCr layout.

Source

pub fn is_oklab(&self) -> bool

Whether this is an Oklab layout.

Source

pub fn is_planar(&self) -> bool

Whether this layout is planar (not interleaved).

Source

pub fn relationship(&self) -> Option<PlaneRelationship>

The plane relationship, if planar.

Source

pub fn max_v_subsample(&self) -> u8

Maximum vertical subsampling factor across all planes.

Returns 1 for interleaved or non-subsampled layouts.

Source

pub fn max_h_subsample(&self) -> u8

Maximum horizontal subsampling factor across all planes.

Returns 1 for interleaved or non-subsampled layouts.

Source

pub fn mask_where(&self, f: impl Fn(PlaneSemantic) -> bool) -> PlaneMask

Build a PlaneMask from a predicate on plane semantics.

Returns PlaneMask::NONE for interleaved layouts.

Source

pub fn luma_mask(&self) -> PlaneMask

Mask of luminance-like planes (Luma, Gray, OklabL).

Source

pub fn chroma_mask(&self) -> PlaneMask

Mask of chroma planes (Cb, Cr, OklabA, OklabB).

Source

pub fn alpha_mask(&self) -> PlaneMask

Mask of alpha planes.

Trait Implementations§

Source§

impl Clone for PlaneLayout

Source§

fn clone(&self) -> PlaneLayout

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 Debug for PlaneLayout

Source§

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

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

impl Display for PlaneLayout

Source§

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

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

impl Eq for PlaneLayout

Source§

impl PartialEq for PlaneLayout

Source§

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

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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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.