Type Definition imgref::ImgRef[][src]

type ImgRef<'a, Pixel> = Img<&'a [Pixel]>;

Reference to pixels inside another image. Pass this structure by value (i.e. ImgRef, not &ImgRef).

Only width of pixels of every stride can be modified. The buf may be longer than height*stride, but the extra space should be ignored.

Implementations

impl<'a, T> ImgRef<'a, T>[src]

#[must_use]pub fn sub_image(
    &self,
    left: usize,
    top: usize,
    width: usize,
    height: usize
) -> Self
[src]

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

Panics

It will panic if sub_image is outside of the image area (left + width must be <= container width, etc.)

#[must_use]pub fn rows(&self) -> RowsIter<'_, T>

Notable traits for RowsIter<'a, T>

impl<'a, T: 'a> Iterator for RowsIter<'a, T> type Item = &'a [T];
[src]

Iterate over whole rows of pixels as slices

Panics

If stride is 0

See also pixels()

pub fn iter(&self) -> Iter<'_, T>[src]

👎 Deprecated:

Size of this buffer is unpredictable. Use .rows() instead

Deprecated

Note: it iterates all pixels in the underlying buffer, not just limited by width/height.

impl<'a, T: Clone> ImgRef<'a, T>[src]

#[must_use]pub fn to_contiguous_buf(&self) -> (Cow<'_, [T]>, usize, usize)[src]

Returns a reference to the buffer, width, height. Guarantees that the buffer is contiguous, i.e. it’s width*height elements long, and [x + y*width] addresses each pixel.

It will create a copy if the buffer isn’t contiguous (width != stride). For a more efficient version, see into_contiguous_buf()

impl<'a, T: Copy> ImgRef<'a, T>[src]

#[must_use]pub fn pixels(&self) -> PixelsIter<'_, T>

Notable traits for PixelsIter<'a, T>

impl<'a, T: Copy + 'a> Iterator for PixelsIter<'a, T> type Item = T;
[src]

Iterate width*height pixels in the Img, ignoring padding area

Panics

if width is 0

impl<'a, T> ImgRef<'a, T>[src]

#[must_use]pub fn pixels_ref(&self) -> PixelsRefIter<'_, T>

Notable traits for PixelsRefIter<'a, T>

impl<'a, T: 'a> Iterator for PixelsRefIter<'a, T> type Item = &'a T;
[src]

Iterate width*height pixels in the Img, by reference, ignoring padding area

Panics

if width is 0

Trait Implementations

impl<'a, T: Eq> Eq for ImgRef<'a, T>[src]

impl<'a, T: Hash> Hash for ImgRef<'a, T>[src]

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

impl<'a, 'b, T, U> PartialEq<Img<&'b mut [U]>> for ImgRef<'a, T> where
    T: PartialEq<U>, 
[src]

impl<'a, T, U> PartialEq<Img<Vec<U, Global>>> for ImgRef<'a, T> where
    T: PartialEq<U>, 
[src]