Struct image_texel::image::ImageMut
source · [−]pub struct ImageMut<'buf, Layout = &'buf mut Bytes> { /* private fields */ }Expand description
A writeable reference to an image buffer.
Implementations
sourceimpl<'data, L> ImageMut<'data, L>
impl<'data, L> ImageMut<'data, L>
sourcepub fn as_bytes(&self) -> &[u8] where
L: Layout,
pub fn as_bytes(&self) -> &[u8] where
L: Layout,
Get a reference to those bytes used by the layout.
sourcepub fn as_bytes_mut(&mut self) -> &mut [u8] where
L: Layout,
pub fn as_bytes_mut(&mut self) -> &mut [u8] where
L: Layout,
Get a mutable reference to those bytes used by the layout.
pub fn layout(&self) -> &L
sourcepub fn fits(&self, other: &impl Layout) -> bool
pub fn fits(&self, other: &impl Layout) -> bool
Check if a call to ImageMut::with_layout would succeed, without consuming this reference.
sourcepub fn with_layout<M>(self, layout: M) -> Option<ImageMut<'data, M>> where
M: Layout,
pub fn with_layout<M>(self, layout: M) -> Option<ImageMut<'data, M>> where
M: Layout,
Change this view to a different layout.
This returns Some if the layout fits the underlying data, and None otherwise. Use
ImageMut::fits to check this property in a separate call. Note that the new layout
need not be related to the old layout in any other way.
sourcepub fn decay<M>(self) -> Option<ImageMut<'data, M>> where
M: Decay<L>,
M: Layout,
pub fn decay<M>(self) -> Option<ImageMut<'data, M>> where
M: Decay<L>,
M: Layout,
Decay into a image with less specific layout.
See Image::decay.
sourcepub fn to_owned(&self) -> Image<L> where
L: Layout + Clone,
pub fn to_owned(&self) -> Image<L> where
L: Layout + Clone,
Copy the bytes and layout to an owned container.
sourcepub fn as_slice(&self) -> &[L::Sample] where
L: SliceLayout,
pub fn as_slice(&self) -> &[L::Sample] where
L: SliceLayout,
Get a slice of the individual samples in the layout.
sourcepub fn as_mut_slice(&mut self) -> &mut [L::Sample] where
L: SliceLayout,
pub fn as_mut_slice(&mut self) -> &mut [L::Sample] where
L: SliceLayout,
Get a mutable slice of the individual samples in the layout.
sourcepub fn as_texels<P>(&self, pixel: Texel<P>) -> &[P]
pub fn as_texels<P>(&self, pixel: Texel<P>) -> &[P]
View this buffer as a slice of pixels.
This reinterprets the bytes of the buffer. It can be used to view the buffer as any kind of pixel, regardless of its association with the layout. Use it with care.
An alternative way to get a slice of texels when a layout has an inherent texel type is
Self::as_slice.
sourcepub fn as_mut_texels<P>(&mut self, pixel: Texel<P>) -> &mut [P]
pub fn as_mut_texels<P>(&mut self, pixel: Texel<P>) -> &mut [P]
View this buffer as a slice of pixels.
This reinterprets the bytes of the buffer. It can be used to view the buffer as any kind of pixel, regardless of its association with the layout. Use it with care.
An alternative way to get a slice of texels when a layout has an inherent texel type is
Self::as_mut_slice.
sourcepub fn into_slice(self) -> &'data [L::Sample] where
L: SliceLayout,
pub fn into_slice(self) -> &'data [L::Sample] where
L: SliceLayout,
Turn into a slice of the individual samples in the layout.
This preserves the lifetime with which the layout is borrowed from the underlying image,
and the ImageMut need not stay alive.
sourcepub fn into_mut_slice(self) -> &'data mut [L::Sample] where
L: SliceLayout,
pub fn into_mut_slice(self) -> &'data mut [L::Sample] where
L: SliceLayout,
Turn into a mutable slice of the individual samples in the layout.
This preserves the lifetime with which the layout is borrowed from the underlying image,
and the ImageMut need not stay alive.
sourcepub fn get_texel<P>(&self, coord: Coord) -> Option<P> where
L: Raster<P>,
pub fn get_texel<P>(&self, coord: Coord) -> Option<P> where
L: Raster<P>,
Retrieve a single texel from a raster image.
sourcepub fn put_texel<P>(&mut self, coord: Coord, texel: P) where
L: RasterMut<P>,
pub fn put_texel<P>(&mut self, coord: Coord, texel: P) where
L: RasterMut<P>,
Put a single texel to a raster image.
sourcepub fn shade<P>(&mut self, f: impl FnMut(u32, u32, &mut P)) where
L: RasterMut<P>,
pub fn shade<P>(&mut self, f: impl FnMut(u32, u32, &mut P)) where
L: RasterMut<P>,
Call a function on each texel of this raster image.
The order of evaluation is not defined although certain layouts may offer more specific guarantees. In general, one can expect that layouts call the function in a cache-efficient manner if they are aware of a better iteration strategy.
Trait Implementations
impl<'buf, Layout: Eq> Eq for ImageMut<'buf, Layout>
impl<'buf, Layout> StructuralEq for ImageMut<'buf, Layout>
impl<'buf, Layout> StructuralPartialEq for ImageMut<'buf, Layout>
Auto Trait Implementations
impl<'buf, Layout> RefUnwindSafe for ImageMut<'buf, Layout> where
Layout: RefUnwindSafe,
impl<'buf, Layout> Send for ImageMut<'buf, Layout> where
Layout: Send,
impl<'buf, Layout> Sync for ImageMut<'buf, Layout> where
Layout: Sync,
impl<'buf, Layout> Unpin for ImageMut<'buf, Layout> where
Layout: Unpin,
impl<'buf, Layout = &'buf mut Bytes> !UnwindSafe for ImageMut<'buf, Layout>
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