pub type ImgRefMut<'slice, Pixel> = Img<&'slice mut [Pixel]>;Expand description
Same as ImgRef, but mutable
Pass this structure by value (i.e. ImgRef, not &ImgRef).
Aliased Type§
pub struct ImgRefMut<'slice, Pixel> {
pub buf: &'slice mut [Pixel],
pub stride: usize,
pub width: u32,
pub height: u32,
}Fields§
§buf: &'slice mut [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> ImgRefMut<'slice, T>
impl<'slice, T> ImgRefMut<'slice, T>
Sourcepub fn sub_image(
&'slice self,
left: usize,
top: usize,
width: usize,
height: usize,
) -> ImgRef<'slice, T>
pub fn sub_image( &'slice self, left: usize, top: usize, width: usize, height: usize, ) -> ImgRef<'slice, T>
Turn this into immutable reference, and slice a subregion of it
Sourcepub fn sub_image_mut(
&mut self,
left: usize,
top: usize,
width: usize,
height: usize,
) -> ImgRefMut<'_, T>
pub fn sub_image_mut( &mut self, left: usize, top: usize, width: usize, height: usize, ) -> ImgRefMut<'_, T>
Slices this image reference to produce another reference to a subregion of it.
Note that mutable borrows are exclusive, so it’s not possible to have more than one mutable subimage at a time.
§Panics
If the coordinates are out of bounds
Sourcepub fn into_sub_image_mut(
self,
left: usize,
top: usize,
width: usize,
height: usize,
) -> Self
pub fn into_sub_image_mut( self, left: usize, top: usize, width: usize, height: usize, ) -> Self
Transforms this image reference to refer to a subregion.
This is identical in behavior to ImgRefMut::sub_image_mut(), except that it returns an
ImgRefMut with the same lifetime, rather than a reborrow with a shorter lifetime.
§Panics
If the coordinates are out of bounds