Skip to main content

MultiPlaneImage

Struct MultiPlaneImage 

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

A multi-plane image where each plane is an independent pixel buffer.

Combines a PlaneLayout (metadata describing plane count, semantics, subsampling, and relationship) with actual pixel buffers. Each buffer corresponds to one plane in the layout.

§Examples

use zenpixels::{MultiPlaneImage, PlaneLayout, ChannelType, PixelBuffer, PixelDescriptor};

let layout = PlaneLayout::ycbcr_444(ChannelType::U8);
let y = PixelBuffer::new(1920, 1080, PixelDescriptor::GRAY8);
let cb = PixelBuffer::new(1920, 1080, PixelDescriptor::GRAY8);
let cr = PixelBuffer::new(1920, 1080, PixelDescriptor::GRAY8);

let img = MultiPlaneImage::new(layout, vec![y, cb, cr]);
assert_eq!(img.plane_count(), 3);
assert!(img.layout().is_ycbcr());

Implementations§

Source§

impl MultiPlaneImage

Source

pub fn new(layout: PlaneLayout, buffers: Vec<PixelBuffer>) -> MultiPlaneImage

Create a new multi-plane image from a layout and corresponding buffers.

§Panics

Debug-asserts that the number of buffers matches the planar plane count.

Source

pub fn with_origin(self, ctx: Arc<ColorContext>) -> MultiPlaneImage

Attach a color context.

Source

pub fn layout(&self) -> &PlaneLayout

The layout describing this image’s plane organization.

Source

pub fn plane_count(&self) -> usize

Number of planes.

Source

pub fn buffer(&self, idx: usize) -> Option<&PixelBuffer>

Access a single buffer by index.

Source

pub fn buffer_mut(&mut self, idx: usize) -> Option<&mut PixelBuffer>

Access a single buffer mutably by index.

Source

pub fn buffers(&self) -> &[PixelBuffer]

Access all buffers.

Source

pub fn buffers_mut(&mut self) -> &mut [PixelBuffer]

Access all buffers mutably.

Source

pub fn origin(&self) -> Option<&Arc<ColorContext>>

The optional color context shared across all planes.

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