Struct tiny_skia::Pixmap

source ·
pub struct Pixmap { /* private fields */ }
Expand description

A container that owns premultiplied RGBA pixels.

The data is not aligned, therefore width == stride.

Implementations§

source§

impl Pixmap

source

pub fn new(width: u32, height: u32) -> Option<Self>

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.

source

pub fn from_vec(data: Vec<u8>, size: IntSize) -> Option<Self>

Creates a new pixmap by taking ownership over an image buffer (premultiplied RGBA pixels).

The size needs to match the data provided.

Pixmap’s width is limited by i32::MAX/4.

source

pub fn decode_png(data: &[u8]) -> Result<Self, DecodingError>

Decodes a PNG data into a Pixmap.

Only 8-bit images are supported. Index PNGs are not supported.

source

pub fn load_png<P: AsRef<Path>>(path: P) -> Result<Self, DecodingError>

Loads a PNG file into a Pixmap.

Only 8-bit images are supported. Index PNGs are not supported.

source

pub fn encode_png(&self) -> Result<Vec<u8>, EncodingError>

Encodes pixmap into a PNG data.

source

pub fn save_png<P: AsRef<Path>>(&self, path: P) -> Result<(), EncodingError>

Saves pixmap as a PNG file.

source

pub fn as_ref(&self) -> PixmapRef<'_>

Returns a container that references Pixmap’s data.

source

pub fn as_mut(&mut self) -> PixmapMut<'_>

Returns a container that references Pixmap’s data.

source

pub fn width(&self) -> u32

Returns pixmap’s width.

source

pub fn height(&self) -> u32

Returns pixmap’s height.

source

pub fn fill(&mut self, color: Color)

Fills the entire pixmap with a specified color.

source

pub fn data(&self) -> &[u8]

Returns the internal data.

Byteorder: RGBA

source

pub fn data_mut(&mut self) -> &mut [u8]

Returns the mutable internal data.

Byteorder: RGBA

source

pub fn pixel(&self, x: u32, y: u32) -> Option<PremultipliedColorU8>

Returns a pixel color.

Returns None when position is out of bounds.

source

pub fn pixels_mut(&mut self) -> &mut [PremultipliedColorU8]

Returns a mutable slice of pixels.

source

pub fn pixels(&self) -> &[PremultipliedColorU8]

Returns a slice of pixels.

source

pub fn take(self) -> Vec<u8>

Consumes the internal data.

Byteorder: RGBA

source

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.

source§

impl Pixmap

source

pub fn fill_rect( &mut self, rect: Rect, paint: &Paint<'_>, transform: Transform, clip_mask: Option<&ClipMask> ) -> Option<()>

Draws a filled rectangle onto the pixmap.

See PixmapMut::fill_rect for details.

source

pub fn fill_path( &mut self, path: &Path, paint: &Paint<'_>, fill_rule: FillRule, transform: Transform, clip_mask: Option<&ClipMask> ) -> Option<()>

Draws a filled path onto the pixmap.

See PixmapMut::fill_path for details.

source

pub fn stroke_path( &mut self, path: &Path, paint: &Paint<'_>, stroke: &Stroke, transform: Transform, clip_mask: Option<&ClipMask> ) -> Option<()>

Strokes a path.

See PixmapMut::stroke_path for details.

source

pub fn draw_pixmap( &mut self, x: i32, y: i32, pixmap: PixmapRef<'_>, paint: &PixmapPaint, transform: Transform, clip_mask: Option<&ClipMask> ) -> Option<()>

Draws a Pixmap on top of the current Pixmap.

See PixmapMut::draw_pixmap for details.

Trait Implementations§

source§

impl Clone for Pixmap

source§

fn clone(&self) -> Pixmap

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Pixmap

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl PartialEq for Pixmap

source§

fn eq(&self, other: &Pixmap) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl StructuralPartialEq for Pixmap

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.