pub struct StridedBufferMut<'data> { /* private fields */ }Expand description
A reference to mutable byte of a strided matrix.
This can be constructed from a mutably borrowed image that is currently set to a strided layout such as a matrix. It can be regarded as a generalization to the standard matrix layout. Alternatively, it can be constructed directly from a mutable reference to raw bytes.
§Usage
Here is an example of filling a matrix-like image with a constant value.
use image_texel::layout::Matrix;
use image_texel::image::{StridedBufferRef, StridedBufferMut, Image};
let layout = Matrix::<u32>::width_and_height(4, 4).unwrap();
let mut image = Image::new(layout);
let fill = StridedBufferRef::with_repeated_element(&0x42u32, 4, 4);
StridedBufferMut::new(&mut image).copy_from_image(fill);
assert_eq!(image.as_slice(), &[0x42; 16]);Implementations§
Source§impl<'data> StridedBufferMut<'data>
impl<'data> StridedBufferMut<'data>
Sourcepub fn new(image: &'data mut Image<impl StridedLayout>) -> Self
pub fn new(image: &'data mut Image<impl StridedLayout>) -> Self
Construct a mutable reference to a strided image buffer.
Sourcepub fn with_bytes(
layout: StridedBytes,
content: &'data mut [u8],
) -> Option<Self>
pub fn with_bytes( layout: StridedBytes, content: &'data mut [u8], ) -> Option<Self>
View bytes mutably under a certain strided layout.
Unlike an image, the data need only be aligned to the element mentioned in the layout and
not to the maximum alignment.
Sourcepub fn shrink_element(&mut self, new: TexelLayout) -> TexelLayout
pub fn shrink_element(&mut self, new: TexelLayout) -> TexelLayout
Shrink the element’s size or alignment.
Sourcepub fn copy_from_image(&mut self, source: StridedBufferRef<'_>)
pub fn copy_from_image(&mut self, source: StridedBufferRef<'_>)
Copy the bytes from another image.
The source must have the same width, height, and element size.
Sourcepub fn as_ref(&self) -> StridedBufferRef<'_>
pub fn as_ref(&self) -> StridedBufferRef<'_>
Borrow this as a reference to an immutable byte matrix.
Sourcepub fn into_ref(self) -> StridedBufferRef<'data>
pub fn into_ref(self) -> StridedBufferRef<'data>
Convert this into a reference to an immutable byte matrix.