[−][src]Struct tiny_skia::Pixmap
A container of premultiplied RGBA pixels.
The data is not aligned, therefore width == stride.
Implementations
impl Pixmap
[src]
pub fn new(width: u32, height: u32) -> Option<Self>
[src]
Allocates a new pixmap.
A pixmap is filled with transparent black by default, aka (0, 0, 0, 0).
Zero size in an error.
Pixmap's width is limited by i32::MAX/4.
pub fn width(&self) -> u32
[src]
Returns pixmap's width.
pub fn height(&self) -> u32
[src]
Returns pixmap's height.
pub fn data(&self) -> &[u8]
[src]
Returns the internal data.
Bytes are ordered as RGBA.
pub fn data_mut(&mut self) -> &mut [u8]
[src]
Returns the mutable internal data.
Bytes are ordered as RGBA.
pub fn take(self) -> Vec<u8>
[src]
Consumes the internal data.
Bytes are ordered as 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) -> &[PremultipliedColorU8]
[src]
Returns a slice of pixels.
pub fn pixels_mut(&mut self) -> &mut [PremultipliedColorU8]
[src]
Returns a mutable slice of pixels.
pub fn clone_rect(&self, rect: IntRect) -> Option<Self>
[src]
Returns a copy of the pixmap that intersects the rect
.
Returns None
when Pixmap
's rect doesn't contain rect
.
pub fn fill(&mut self, color: Color)
[src]
Fills the entire pixmap with a specified color.
pub fn decode_png(data: &[u8]) -> Result<Self, DecodingError>
[src]
Decodes a PNG data into a Pixmap
.
Only 8-bit images are supported. Index PNGs are not supported.
pub fn load_png<P: AsRef<Path>>(path: P) -> Result<Self, DecodingError>
[src]
Loads a PNG file into a Pixmap
.
Only 8-bit images are supported. Index PNGs are not supported.
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 Clone for Pixmap
[src]
impl Debug for Pixmap
[src]
impl From<Pixmap> for Canvas
[src]
impl PartialEq<Pixmap> for Pixmap
[src]
impl StructuralPartialEq for Pixmap
[src]
Auto Trait Implementations
impl RefUnwindSafe for Pixmap
impl Send for Pixmap
impl Sync for Pixmap
impl Unpin for Pixmap
impl UnwindSafe for Pixmap
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>,