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 decode_png(data: &[u8]) -> Result<Self, DecodingError>
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.
sourcepub fn load_png<P: AsRef<Path>>(path: P) -> Result<Self, DecodingError>
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.
sourcepub fn encode_png(&self) -> Result<Vec<u8>, EncodingError>
pub fn encode_png(&self) -> Result<Vec<u8>, EncodingError>
Encodes pixmap into a PNG data.
sourcepub fn save_png<P: AsRef<Path>>(&self, path: P) -> Result<(), EncodingError>
pub fn save_png<P: AsRef<Path>>(&self, path: P) -> Result<(), EncodingError>
Saves pixmap as a PNG file.
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.
Trait Implementations§
impl StructuralPartialEq for Pixmap
Auto Trait Implementations§
impl Freeze for Pixmap
impl RefUnwindSafe for Pixmap
impl Send for Pixmap
impl Sync for Pixmap
impl Unpin for Pixmap
impl UnwindSafe for Pixmap
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)