Type Alias imgref::ImgVec

source ·
pub type ImgVec<Pixel> = Img<Vec<Pixel>>;
Expand description

Image owning its pixels.

A 2D array of pixels. The pixels are oriented top-left first and rows are stride pixels wide.

If size of the buf is larger than width*height, then any excess space is a padding (see width_padded()/height_padded()).

Aliased Type§

struct ImgVec<Pixel> {
    pub buf: Vec<Pixel>,
    pub stride: usize,
    pub width: u32,
    pub height: u32,
}

Fields§

§buf: Vec<Pixel>
👎Deprecated: Don’t access struct fields directly. Use buf(), buf_mut() or into_buf()

Storage for the pixels. Usually Vec<Pixel> or &[Pixel]. See ImgVec and ImgRef.

Note that future version will make this field private. Use .rows() and .pixels() iterators where possible, or buf()/buf_mut()/into_buf().

§stride: usize
👎Deprecated: Don’t access struct fields directly. Use stride()

Number of pixels to skip in the container to advance to the next row.

Note: pixels between width and stride may not be usable, and may not even exist in the last row.

§width: u32
👎Deprecated: Don’t access struct fields directly. Use width()

Width of the image in pixels.

Note that this isn’t same as the width of the row in the buf, see stride

§height: u32
👎Deprecated: Don’t access struct fields directly. Use height()

Height of the image in pixels.

Implementations§

source§

impl<T: Copy> ImgVec<T>

source

pub fn pixels(&self) -> PixelsIter<'_, T>

If you want to iterate in parallel, parallelize rows() instead.

Panics

if width is 0

source

pub fn pixels_mut(&mut self) -> PixelsIterMut<'_, T>

If you want to iterate in parallel, parallelize rows() instead.

Panics

if width is 0

source§

impl<T> ImgVec<T>

source

pub fn sub_image_mut( &mut self, left: usize, top: usize, width: usize, height: usize ) -> ImgRefMut<'_, T>

Create a mutable view into a region within the image. See sub_image() for read-only views.

source

pub fn sub_image( &self, left: usize, top: usize, width: usize, height: usize ) -> ImgRef<'_, T>

Make a reference for a part of the image, without copying any pixels.

source

pub fn as_ref(&self) -> ImgRef<'_, T>

Make a reference to this image to pass it to functions without giving up ownership

The reference should be passed by value (ImgRef, not &ImgRef).

If you need a mutable reference, see as_mut() and sub_image_mut()

source

pub fn as_mut(&mut self) -> ImgRefMut<'_, T>

Make a mutable reference to the entire image

The reference should be passed by value (ImgRefMut, not &mut ImgRefMut).

See also sub_image_mut() and rows_mut()

source

pub fn rows(&self) -> RowsIter<'_, T>

Iterate over rows of the image as slices

Each slice is guaranteed to be exactly width pixels wide.

This iterator is a good candidate for parallelization (e.g. rayon’s par_bridge())

source

pub fn rows_mut(&mut self) -> RowsIterMut<'_, T>

Iterate over rows of the image as mutable slices

Each slice is guaranteed to be exactly width pixels wide.

This iterator is a good candidate for parallelization (e.g. rayon’s par_bridge())

Trait Implementations§

source§

impl<T: Hash> Hash for ImgVec<T>

source§

fn hash<H: Hasher>(&self, state: &mut H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl<'a, T, U> PartialEq<Img<&'a [U]>> for ImgVec<T>
where T: PartialEq<U>,

source§

fn eq(&self, other: &ImgRef<'a, U>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<T, U> PartialEq<Img<Vec<U>>> for ImgVec<T>
where T: PartialEq<U>,

source§

fn eq(&self, other: &ImgVec<U>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<T: Eq> Eq for ImgVec<T>