pub struct PixmapRef<'a> {
data: &'a [u8],
size: IntSize,
}
Expand description
A container that references premultiplied RGBA pixels.
Can be created from Pixmap
or from a user provided data.
The data is not aligned, therefore width == stride.
Fields§
§data: &'a [u8]
§size: IntSize
Implementations§
source§impl<'a> PixmapRef<'a>
impl<'a> PixmapRef<'a>
pub(crate) fn gather(&self, index: u32x8) -> [PremultipliedColorU8; 8]
source§impl<'a> PixmapRef<'a>
impl<'a> PixmapRef<'a>
sourcepub fn from_bytes(data: &'a [u8], width: u32, height: u32) -> Option<Self>
pub fn from_bytes(data: &'a [u8], width: u32, height: u32) -> Option<Self>
Creates a new PixmapRef
from bytes.
The size must be at least size.width() * size.height() * BYTES_PER_PIXEL
.
Zero size in an error. Width is limited by i32::MAX/4.
The data
is assumed to have premultiplied RGBA pixels (byteorder: RGBA).
sourcepub fn to_owned(&self) -> Pixmap
pub fn to_owned(&self) -> Pixmap
Creates a new Pixmap
from the current data.
Clones the underlying data.
sourcepub(crate) fn rect(&self) -> ScreenIntRect
pub(crate) fn rect(&self) -> ScreenIntRect
Returns pixmap’s rect.
sourcepub fn pixel(&self, x: u32, y: u32) -> Option<PremultipliedColorU8>
pub fn pixel(&self, x: u32, y: u32) -> Option<PremultipliedColorU8>
Returns a pixel color.
Returns None
when position is out of bounds.
sourcepub fn pixels(&self) -> &'a [PremultipliedColorU8]
pub fn pixels(&self) -> &'a [PremultipliedColorU8]
Returns a slice of pixels.
sourcepub fn clone_rect(&self, rect: IntRect) -> Option<Pixmap>
pub fn clone_rect(&self, rect: IntRect) -> Option<Pixmap>
Returns a copy of the pixmap that intersects the rect
.
Returns None
when Pixmap
’s rect doesn’t contain rect
.
Trait Implementations§
impl<'a> Copy for PixmapRef<'a>
impl<'a> StructuralPartialEq for PixmapRef<'a>
Auto Trait Implementations§
impl<'a> Freeze for PixmapRef<'a>
impl<'a> RefUnwindSafe for PixmapRef<'a>
impl<'a> Send for PixmapRef<'a>
impl<'a> Sync for PixmapRef<'a>
impl<'a> Unpin for PixmapRef<'a>
impl<'a> UnwindSafe for PixmapRef<'a>
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)