Skip to main content

PlaneGeometry

Struct PlaneGeometry 

Source
pub struct PlaneGeometry { /* private fields */ }
Expand description

Describes the geometry of a plane, including dimensions and padding.

This struct contains all the information needed to interpret the layout of a plane’s data buffer, including the visible dimensions and the padding on all four sides.

The stride represents the number of pixels per row in the data buffer, which is equal to width + pad_left + pad_right.

Implementations§

Source§

impl PlaneGeometry

Source

pub fn new( width: usize, height: usize, pad_left: usize, pad_right: usize, pad_top: usize, pad_bottom: usize, subsampling_x: u8, subsampling_y: u8, ) -> Option<Self>

Returns a new PlaneGeometry with the given dimensions, padding and subsampling.

Will return None if:

  • width, height, subsampling_x or subsampling_y are zero or
  • the data stride would overflow a usize.
Source

pub fn unpadded( width: usize, height: usize, subsampling_x: u8, subsampling_y: u8, ) -> Option<Self>

Returns a new PlaneGeometry with the given dimensions, subsampling and zero padding.

Returns None if width, height, subsampling_x or subsampling_y are zero.

Source

pub fn width(&self) -> usize

Width of the visible area in pixels.

Guaranteed to be non-zero.

Source

pub fn height(&self) -> usize

Height of the visible area in pixels.

Guaranteed to be non-zero.

Source

pub fn stride(&self) -> usize

Data stride (pixels per row in the buffer, including padding).

Guaranteed to be non-zero.

Source

pub fn pad_left(&self) -> usize

Number of padding pixels on the left side.

Source

pub fn pad_right(&self) -> usize

Number of padding pixels on the right side.

Source

pub fn pad_top(&self) -> usize

Number of padding pixels on the top.

Source

pub fn pad_bottom(&self) -> usize

Number of padding pixels on the bottom.

Source

pub fn subsampling_x(&self) -> u8

The horizontal subsampling ratio of this plane compared to the luma plane.

Guaranteed to be non-zero, and 1 if not subsampled.

Source

pub fn subsampling_y(&self) -> u8

The horizontal subsampling ratio of this plane compared to the luma plane.

Guaranteed to be non-zero, and 1 if not subsampled.

Source

pub fn for_subsampling( self, subsampling: ChromaSubsampling, ) -> Result<Option<Self>, SubsamplingError>

Returns a new PlaneGeometry based on self and according to subsampling.

Returns:

  • Ok(None) if the subsampling specifies no other planes (i.e. monochrome),
  • Ok(Some(g)) if self was successfully subsampled into a new geometry g,
  • Err(..) if self could not be subsampled into a new geometry, for example due to self having an odd width or height.
§Errors

See SubsamplingError.

Source

pub fn data_origin(&self) -> usize

Returns the index for the first visible pixel.

Source

pub fn alloc_height(&self) -> usize

Returns the total height of the plane, including padding.

Source

pub fn alloc_size(&self) -> usize

Returns the total allocation size of the plane, including padding.

Trait Implementations§

Source§

impl Clone for PlaneGeometry

Source§

fn clone(&self) -> PlaneGeometry

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 PlaneGeometry

Source§

impl Debug for PlaneGeometry

Source§

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

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

impl Eq for PlaneGeometry

Source§

impl PartialEq for PlaneGeometry

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for PlaneGeometry

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.