Skip to main content

PlaneMatrices

Struct PlaneMatrices 

Source
pub struct PlaneMatrices<T, const N: usize> { /* private fields */ }
Expand description

An array of byte matrices.

This type is optimized for the concrete layout type of matrix planes.

§Examples

use image_texel::image::Image;
use image_texel::layout::{PlaneMatrices, Matrix};
use image_texel::texels::U8;

// Imagine a JPEG with progressive DCT coefficient planes.
let rough = Matrix::from_width_height(U8, 8, 8).unwrap();
let dense = Matrix::from_width_height(U8, 64, 64).unwrap();

// The assembled layout can be used to access the disjoint planes.
let matrices = PlaneMatrices::new(U8, [rough, dense]);
let rough = matrices.plane_ref(0).unwrap();
let dense = matrices.plane_ref(1).unwrap();

let buffer = Image::new(&matrices);
let rough_coeffs = &buffer.as_buf()[rough.texel_range()];
assert_eq!(rough_coeffs.len(), 8 * 8);

let dense_coeffs = &buffer.as_buf()[dense.texel_range()];
assert_eq!(dense_coeffs.len(), 64 * 64);

// The coefficient planes are disjoint and well-ordered.
assert!(rough_coeffs.as_ptr_range().end <= dense_coeffs.as_ptr());

Implementations§

Source§

impl<T, const N: usize> PlaneMatrices<T, N>

Source

pub fn new(texel: Texel<T>, inner: [Matrix<T>; N]) -> Self

Construct from separate matrices.

Relocates each consecutive matrix such that they do not overlap.

§Panics

This method panics if the overall layout length would exceed isize::MAX.

Source

pub fn from_repeated(matrix: Matrix<T>) -> Self

Source

pub fn plane_ref(&self, idx: usize) -> Option<&Relocated<Matrix<T>>>

Return a reference to one relocated matrix layout.

Trait Implementations§

Source§

impl<T: Clone, const N: usize> Clone for PlaneMatrices<T, N>

Source§

fn clone(&self) -> PlaneMatrices<T, N>

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<T, const N: usize> Decay<PlaneMatrices<T, N>> for PlaneBytes<N>

Source§

fn decay(from: PlaneMatrices<T, N>) -> PlaneBytes<N>

Source§

impl<T, const N: usize> Layout for PlaneMatrices<T, N>

Source§

fn byte_len(&self) -> usize

Source§

impl<T, const N: usize> PlaneOf<PlaneMatrices<T, N>> for usize

Source§

type Plane = Relocated<Matrix<T>>

Source§

fn get_plane(self, layout: &PlaneMatrices<T, N>) -> Option<Self::Plane>

Get the layout describing the plane.
Source§

impl<T, const N: usize> SliceLayout for PlaneMatrices<T, N>

Source§

type Sample = T

The sample type itself.
Source§

fn sample(&self) -> Texel<Self::Sample>

Get the sample description.
Source§

fn len(&self) -> usize

The number of samples. Read more
Source§

fn as_index(&self) -> TexelRange<Self::Sample>

Auto Trait Implementations§

§

impl<T, const N: usize> Freeze for PlaneMatrices<T, N>

§

impl<T, const N: usize> RefUnwindSafe for PlaneMatrices<T, N>
where T: RefUnwindSafe,

§

impl<T, const N: usize> Send for PlaneMatrices<T, N>
where T: Send,

§

impl<T, const N: usize> Sync for PlaneMatrices<T, N>
where T: Sync,

§

impl<T, const N: usize> Unpin for PlaneMatrices<T, N>
where T: Unpin,

§

impl<T, const N: usize> UnsafeUnpin for PlaneMatrices<T, N>

§

impl<T, const N: usize> UnwindSafe for PlaneMatrices<T, N>
where T: UnwindSafe,

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.