pub type ImgRef<'slice, Pixel> = Img<&'slice [Pixel]>;Expand description
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.
Aliased Type§
pub struct ImgRef<'slice, Pixel> {
    pub buf: &'slice [Pixel],
    pub stride: usize,
    pub width: u32,
    pub height: u32,
}Fields§
§buf: &'slice [Pixel]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: usizeNumber 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: u32Width of the image in pixels.
Note that this isn’t same as the width of the row in the buf, see stride
height: u32Height of the image in pixels.
Implementations§
Source§impl<'slice, T> ImgRef<'slice, T>
 
impl<'slice, T> ImgRef<'slice, T>
Source§impl<'a, T: Clone> ImgRef<'a, T>
 
impl<'a, T: Clone> ImgRef<'a, T>
Sourcepub fn to_contiguous_buf(&self) -> (Cow<'a, [T]>, usize, usize)
 
pub fn to_contiguous_buf(&self) -> (Cow<'a, [T]>, usize, usize)
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()
Source§impl<'slice, T: Copy> ImgRef<'slice, T>
 
impl<'slice, T: Copy> ImgRef<'slice, T>
Sourcepub fn pixels(&self) -> PixelsIter<'slice, T> ⓘ
 
pub fn pixels(&self) -> PixelsIter<'slice, T> ⓘ
Iterate width*height pixels in the Img, ignoring padding area
If you want to iterate in parallel, parallelize rows() instead.
§Panics
if width is 0
Source§impl<'slice, T> ImgRef<'slice, T>
 
impl<'slice, T> ImgRef<'slice, T>
Sourcepub fn pixels_ref(&self) -> PixelsRefIter<'slice, T> ⓘ
 
pub fn pixels_ref(&self) -> PixelsRefIter<'slice, T> ⓘ
Iterate width*height pixels in the Img, by reference, ignoring padding area
If you want to iterate in parallel, parallelize rows() instead.
§Panics
if width is 0