Struct tiny_skia::pixmap::PixmapMut

source ·
pub struct PixmapMut<'a> {
    data: &'a mut [u8],
    size: IntSize,
}
Expand description

A container that references mutable 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 mut [u8]§size: IntSize

Implementations§

source§

impl<'a> PixmapMut<'a>

source

pub fn from_bytes(data: &'a mut [u8], width: u32, height: u32) -> Option<Self>

Creates a new PixmapMut 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).

source

pub fn to_owned(&self) -> Pixmap

Creates a new Pixmap from the current data.

Clones the underlying data.

source

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

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(crate) fn size(&self) -> IntSize

Returns pixmap’s size.

source

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

Fills the entire pixmap with a specified color.

source

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

Returns the mutable internal data.

Byteorder: RGBA

source

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

Returns a mutable slice of pixels.

source

pub(crate) fn as_subpixmap(&mut self) -> SubPixmapMut<'_>

Creates SubPixmapMut that contains the whole PixmapMut.

source

pub(crate) fn subpixmap(&mut self, rect: IntRect) -> Option<SubPixmapMut<'_>>

Returns a mutable reference to the pixmap region that intersects the rect.

Returns None when Pixmap’s rect doesn’t contain rect.

source§

impl PixmapMut<'_>

source

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

Draws a filled rectangle onto the pixmap.

This function is usually slower than filling a rectangular path, but it produces better results. Mainly it doesn’t suffer from weird clipping of horizontal/vertical edges.

Used mainly to render a pixmap onto a pixmap.

Returns None when there is nothing to fill or in case of a numeric overflow.

source

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

Draws a filled path onto the pixmap.

source

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

Strokes a path.

Stroking is implemented using two separate algorithms:

  1. If a stroke width is wider than 1px (after applying the transformation), a path will be converted into a stroked path and then filled using fill_path. Which means that we have to allocate a separate Path, that can be 2-3x larger then the original path.
  2. If a stroke width is thinner than 1px (after applying the transformation), we will use hairline stroking, which doesn’t involve a separate path allocation.

Also, if a stroke has a dash array, then path will be converted into a dashed path first and then stroked. Which means a yet another allocation.

source

fn stroke_hairline( path: &Path, paint: &Paint<'_>, line_cap: LineCap, mask: Option<SubMaskRef<'_>>, pixmap: &mut SubPixmapMut<'_>, )

A stroking for paths with subpixel/hairline width.

source

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

Draws a Pixmap on top of the current Pixmap.

The same as filling a rectangle with a pixmap pattern.

source

pub fn apply_mask(&mut self, mask: &Mask)

Applies a masks.

When a Mask is passed to drawing methods, it will be used to mask-out content we’re about to draw. This method masks-out an already drawn content. It’s not as fast, but can be useful when a mask is not available during drawing.

This method is similar to filling the whole pixmap with an another, mask-like pixmap using the DestinationOut blend mode.

Mask must have the same size as Pixmap. No transform or offset are allowed.

Trait Implementations§

source§

impl Debug for PixmapMut<'_>

source§

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

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

impl<'a> PartialEq for PixmapMut<'a>

source§

fn eq(&self, other: &PixmapMut<'a>) -> bool

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

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

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

impl<'a> StructuralPartialEq for PixmapMut<'a>

Auto Trait Implementations§

§

impl<'a> Freeze for PixmapMut<'a>

§

impl<'a> RefUnwindSafe for PixmapMut<'a>

§

impl<'a> Send for PixmapMut<'a>

§

impl<'a> Sync for PixmapMut<'a>

§

impl<'a> Unpin for PixmapMut<'a>

§

impl<'a> !UnwindSafe for PixmapMut<'a>

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, U> TryFrom<U> for T
where U: Into<T>,

source§

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>,

source§

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.