#[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
Interleaved
Interleaved pixel data (channels packed per-pixel).
Planar
Planar pixel data (one buffer per plane).
Fields
planes: Vec<PlaneDescriptor>Descriptor for each plane.
relationship: PlaneRelationshipHow the planes relate to each other.
Implementations§
Source§impl PlaneLayout
impl PlaneLayout
Sourcepub fn ycbcr_444(ct: ChannelType) -> PlaneLayout
pub fn ycbcr_444(ct: ChannelType) -> PlaneLayout
YCbCr 4:4:4 (no subsampling).
Sourcepub fn ycbcr_444_matrix(ct: ChannelType, matrix: YuvMatrix) -> PlaneLayout
pub fn ycbcr_444_matrix(ct: ChannelType, matrix: YuvMatrix) -> PlaneLayout
YCbCr 4:4:4 with a specific matrix.
Sourcepub fn ycbcr_422(ct: ChannelType) -> PlaneLayout
pub fn ycbcr_422(ct: ChannelType) -> PlaneLayout
YCbCr 4:2:2 (horizontal half chroma).
Sourcepub fn ycbcr_420(ct: ChannelType) -> PlaneLayout
pub fn ycbcr_420(ct: ChannelType) -> PlaneLayout
YCbCr 4:2:0 (half chroma in both axes).
Sourcepub fn rgb(ct: ChannelType) -> PlaneLayout
pub fn rgb(ct: ChannelType) -> PlaneLayout
Planar RGB (3 independent planes, no subsampling).
Sourcepub fn rgba(ct: ChannelType) -> PlaneLayout
pub fn rgba(ct: ChannelType) -> PlaneLayout
Planar RGBA (4 independent planes, no subsampling).
Sourcepub fn oklab(ct: ChannelType) -> PlaneLayout
pub fn oklab(ct: ChannelType) -> PlaneLayout
Oklab (L/a/b, 3 planes, no subsampling).
Sourcepub fn oklab_alpha(ct: ChannelType) -> PlaneLayout
pub fn oklab_alpha(ct: ChannelType) -> PlaneLayout
Oklab with alpha (L/a/b/A, 4 planes, no subsampling).
Sourcepub fn gray(ct: ChannelType) -> PlaneLayout
pub fn gray(ct: ChannelType) -> PlaneLayout
Grayscale (single plane, no subsampling).
Sourcepub fn plane_count(&self) -> usize
pub fn plane_count(&self) -> usize
Number of planes (or interleaved channels).
Sourcepub fn planes(&self) -> &[PlaneDescriptor]
pub fn planes(&self) -> &[PlaneDescriptor]
Plane descriptors. Empty slice for interleaved layout.
Sourcepub fn luma_plane_index(&self) -> Option<usize>
pub fn luma_plane_index(&self) -> Option<usize>
Index of the luma/lightness plane, if any.
Sourcepub fn has_subsampling(&self) -> bool
pub fn has_subsampling(&self) -> bool
Whether any plane is subsampled.
Sourcepub fn relationship(&self) -> Option<PlaneRelationship>
pub fn relationship(&self) -> Option<PlaneRelationship>
The plane relationship, if planar.
Sourcepub fn max_v_subsample(&self) -> u8
pub fn max_v_subsample(&self) -> u8
Maximum vertical subsampling factor across all planes.
Returns 1 for interleaved or non-subsampled layouts.
Sourcepub fn max_h_subsample(&self) -> u8
pub fn max_h_subsample(&self) -> u8
Maximum horizontal subsampling factor across all planes.
Returns 1 for interleaved or non-subsampled layouts.
Sourcepub fn mask_where(&self, f: impl Fn(PlaneSemantic) -> bool) -> PlaneMask
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.
Sourcepub fn chroma_mask(&self) -> PlaneMask
pub fn chroma_mask(&self) -> PlaneMask
Mask of chroma planes (Cb, Cr, OklabA, OklabB).
Sourcepub fn alpha_mask(&self) -> PlaneMask
pub fn alpha_mask(&self) -> PlaneMask
Mask of alpha planes.
Trait Implementations§
Source§impl Clone for PlaneLayout
impl Clone for PlaneLayout
Source§fn clone(&self) -> PlaneLayout
fn clone(&self) -> PlaneLayout
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more