Struct image_texel::image::ImageRef
source · [−]pub struct ImageRef<'buf, Layout = &'buf Bytes> { /* private fields */ }Expand description
A read-only view of an image.
Note that this requires its underlying buffer to be highly aligned! For that reason it is not possible to take a reference at an arbitrary number of bytes.
Implementations
sourceimpl<'data, L> ImageRef<'data, L>
impl<'data, L> ImageRef<'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.
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 ImageRef::with_layout would succeed.
sourcepub fn with_layout<M>(self, layout: M) -> Option<ImageRef<'data, M>> where
M: Layout,
pub fn with_layout<M>(self, layout: M) -> Option<ImageRef<'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
ImageRef::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<ImageRef<'data, M>> where
M: Decay<L>,
M: Layout,
pub fn decay<M>(self) -> Option<ImageRef<'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 all bytes to a newly allocated image.
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_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 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.
Trait Implementations
impl<'buf, Layout: Eq> Eq for ImageRef<'buf, Layout>
impl<'buf, Layout> StructuralEq for ImageRef<'buf, Layout>
impl<'buf, Layout> StructuralPartialEq for ImageRef<'buf, Layout>
Auto Trait Implementations
impl<'buf, Layout> RefUnwindSafe for ImageRef<'buf, Layout> where
Layout: RefUnwindSafe,
impl<'buf, Layout> Send for ImageRef<'buf, Layout> where
Layout: Send,
impl<'buf, Layout> Sync for ImageRef<'buf, Layout> where
Layout: Sync,
impl<'buf, Layout> Unpin for ImageRef<'buf, Layout> where
Layout: Unpin,
impl<'buf, Layout> UnwindSafe for ImageRef<'buf, Layout> where
Layout: UnwindSafe,
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
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into)Uses borrowed data to replace owned data, usually by cloning. Read more