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
impl Pixmap
sourcepub fn new(width: u32, height: u32) -> Option<Self>
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.
sourcepub fn from_vec(data: Vec<u8>, size: IntSize) -> Option<Self>
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.
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_mut(&mut self) -> &mut [PremultipliedColorU8]
pub fn pixels_mut(&mut self) -> &mut [PremultipliedColorU8]
Returns a mutable slice of pixels.
sourcepub fn pixels(&self) -> &[PremultipliedColorU8]
pub fn pixels(&self) -> &[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
.
source§impl Pixmap
impl Pixmap
sourcepub fn fill_rect(
&mut self,
rect: Rect,
paint: &Paint<'_>,
transform: Transform,
mask: Option<&Mask>
)
pub fn fill_rect( &mut self, rect: Rect, paint: &Paint<'_>, transform: Transform, mask: Option<&Mask> )
Draws a filled rectangle onto the pixmap.
See PixmapMut::fill_rect
for details.
sourcepub fn fill_path(
&mut self,
path: &Path,
paint: &Paint<'_>,
fill_rule: FillRule,
transform: Transform,
mask: Option<&Mask>
)
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.
See PixmapMut::fill_path
for details.
sourcepub fn stroke_path(
&mut self,
path: &Path,
paint: &Paint<'_>,
stroke: &Stroke,
transform: Transform,
mask: Option<&Mask>
)
pub fn stroke_path( &mut self, path: &Path, paint: &Paint<'_>, stroke: &Stroke, transform: Transform, mask: Option<&Mask> )
Strokes a path.
See PixmapMut::stroke_path
for details.
sourcepub fn draw_pixmap(
&mut self,
x: i32,
y: i32,
pixmap: PixmapRef<'_>,
paint: &PixmapPaint,
transform: Transform,
mask: Option<&Mask>
)
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
.
See PixmapMut::draw_pixmap
for details.
sourcepub fn apply_mask(&mut self, mask: &Mask)
pub fn apply_mask(&mut self, mask: &Mask)
Applies a masks.
See PixmapMut::apply_mask
for details.