Struct CanvasLayout

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

The layout of a full frame, with all planes and color.

Implementations§

Source§

impl CanvasLayout

Source

pub fn with_plane(bytes: PlaneBytes) -> Self

Construct a full frame from a single plane.

Source

pub fn with_planes( layers: &[PlaneBytes], texel: Texel, ) -> Result<Self, LayoutError>

Create from a list of planes, and the texel they describe when merged.

Source

pub fn with_row_layout(rows: &RowLayoutDescription) -> Result<Self, LayoutError>

Create a buffer layout given the layout of a simple, strided matrix.

Source

pub fn with_texel( texel: &Texel, width: u32, height: u32, ) -> Result<Self, LayoutError>

Create a buffer layout from a texel and dimensions.

This is a simplification of with_row_layout which itself is a simplified new.

Source

pub fn texel(&self) -> &Texel

Get the texel represented by the canvas as a whole.

For non-planar images this is exactly the same as the texel of the first place. Otherwise, it is a merged representation.

Source

pub fn color(&self) -> Option<&Color>

Get the color space used by the image.

Source

pub fn texel_index(&self, x: u32, y: u32) -> u64

Returns the index of a texel in a slice of planar image data.

Source

pub fn as_row_layout(&self) -> RowLayoutDescription

Returns a matrix descriptor that can store all bytes.

Note: for the moment, all layouts are row-wise matrices. This will be relaxed in the future to also permit the construction from planar image layouts. In this case, the method will return a descriptor that does not equal this layout. Instead, an image buffer shaped like the returned descriptor can be used to re-arrange all bytes into a simple matrix form.

Source

pub fn width(&self) -> u32

Returns the width of the underlying image in pixels.

Source

pub fn height(&self) -> u32

Returns the height of the underlying image in pixels.

Source

pub fn u64_len(&self) -> u64

Returns the memory usage as a u64.

Source

pub fn byte_len(&self) -> usize

Returns the memory usage as a usize.

Source

pub fn set_color(&mut self, color: Color) -> Result<(), LayoutError>

Set the color of the layout, if compatible with the texel.

Source

pub fn as_plane(&self) -> Option<PlaneBytes>

Trait Implementations§

Source§

impl Clone for CanvasLayout

Source§

fn clone(&self) -> CanvasLayout

Returns a duplicate of the value. Read more
1.0.0 · Source§

const fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for CanvasLayout

Source§

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

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

impl Decay<PlaneBytes> for CanvasLayout

Source§

fn decay(from: PlaneBytes) -> Self

Source§

impl From<&PlaneBytes> for CanvasLayout

Source§

fn from(plane: &PlaneBytes) -> Self

Converts to this type from the input type.
Source§

impl Layout for CanvasLayout

Source§

fn byte_len(&self) -> usize

Source§

impl PartialEq for CanvasLayout

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

const 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 CanvasLayout

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<P, L> PlaneOf<&L> for P
where P: PlaneOf<L>,

Source§

type Plane = <P as PlaneOf<L>>::Plane

Source§

fn get_plane(self, layout: &&L) -> Option<<P as PlaneOf<&L>>::Plane>

Get the layout describing the plane.
Source§

impl<P, L> PlaneOf<&mut L> for P
where P: PlaneOf<L>,

Source§

type Plane = <P as PlaneOf<L>>::Plane

Source§

fn get_plane(self, layout: &&mut L) -> Option<<P as PlaneOf<&mut L>>::Plane>

Get the layout describing the plane.
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.