Struct tiny_skia::PixmapRef [−][src]
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
impl<'a> PixmapRef<'a>
[src]
pub fn from_bytes(data: &'a [u8], width: u32, height: u32) -> Option<Self>
[src]
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).
pub fn to_owned(&self) -> Pixmap
[src]
Creates a new Pixmap
from the current data.
Clones the underlying data.
pub fn width(&self) -> u32
[src]
Returns pixmap’s width.
pub fn height(&self) -> u32
[src]
Returns pixmap’s height.
pub fn data(&self) -> &'a [u8]
[src]
Returns the internal data.
Byteorder: RGBA
pub fn pixel(&self, x: u32, y: u32) -> Option<PremultipliedColorU8>
[src]
Returns a pixel color.
Returns None
when position is out of bounds.
pub fn pixels(&self) -> &'a [PremultipliedColorU8]
[src]
Returns a slice of pixels.
pub fn clone_rect(&self, rect: IntRect) -> Option<Pixmap>
[src]
Returns a copy of the pixmap that intersects the rect
.
Returns None
when Pixmap
’s rect doesn’t contain rect
.
pub fn encode_png(&self) -> Result<Vec<u8>, EncodingError>
[src]
Encodes pixmap into a PNG data.
pub fn save_png<P: AsRef<Path>>(&self, path: P) -> Result<(), EncodingError>
[src]
Saves pixmap as a PNG file.
Trait Implementations
impl<'a> Clone for PixmapRef<'a>
[src]
impl<'a> Copy for PixmapRef<'a>
[src]
impl Debug for PixmapRef<'_>
[src]
impl<'a> PartialEq<PixmapRef<'a>> for PixmapRef<'a>
[src]
impl<'a> StructuralPartialEq for PixmapRef<'a>
[src]
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
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,