pub struct PixmapRef<'a> { /* private fields */ }
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.
Implementations
sourceimpl<'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 fn data(&self) -> &'a [u8]ⓘNotable traits for &mut [u8]impl<'_> Write for &mut [u8]impl<'_> Read for &[u8]
pub fn data(&self) -> &'a [u8]ⓘNotable traits for &mut [u8]impl<'_> Write for &mut [u8]impl<'_> Read for &[u8]
Returns the internal data.
Byteorder: RGBA
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
.
sourcepub fn encode_png(&self) -> Result<Vec<u8>, EncodingError>
pub fn encode_png(&self) -> Result<Vec<u8>, EncodingError>
Encodes pixmap into a PNG data.
Trait Implementations
impl<'a> Copy for PixmapRef<'a>
impl<'a> StructuralPartialEq for PixmapRef<'a>
Auto Trait Implementations
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
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