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<Pixmap>
pub fn new(width: u32, height: u32) -> Option<Pixmap>
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<Pixmap>
pub fn from_vec(data: Vec<u8>, size: IntSize) -> Option<Pixmap>
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<Pixmap, DecodingError>
pub fn decode_png(data: &[u8]) -> Result<Pixmap, DecodingError>
Decodes a PNG data into a Pixmap.
Only 8-bit images are supported. Index PNGs are not supported.
Sourcepub fn load_png<P>(path: P) -> Result<Pixmap, DecodingError>
pub fn load_png<P>(path: P) -> Result<Pixmap, 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>(&self, path: P) -> Result<(), EncodingError>
pub fn save_png<P>(&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§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more