Struct image_texel::image::StridedBufferMut
source · [−]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
sourceimpl<'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.
Auto Trait Implementations
impl<'data> RefUnwindSafe for StridedBufferMut<'data>
impl<'data> Send for StridedBufferMut<'data>
impl<'data> Sync for StridedBufferMut<'data>
impl<'data> Unpin for StridedBufferMut<'data>
impl<'data> !UnwindSafe for StridedBufferMut<'data>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more