pub struct Pixmap { /* private fields */ }
Expand description
A container that owns premultiplied RGBA pixels.
The data is not aligned, therefore width == stride.
Implementations
sourceimpl 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 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 data(&self) -> &[u8]ⓘNotable traits for &mut [u8]impl<'_> Write for &mut [u8]impl<'_> Read for &[u8]
pub fn data(&self) -> &[u8]ⓘNotable traits for &mut [u8]impl<'_> Write for &mut [u8]impl<'_> Read for &[u8]
Returns the internal data.
Byteorder: RGBA
sourcepub fn data_mut(&mut self) -> &mut [u8]ⓘNotable traits for &mut [u8]impl<'_> Write for &mut [u8]impl<'_> Read for &[u8]
pub fn data_mut(&mut self) -> &mut [u8]ⓘNotable traits for &mut [u8]impl<'_> Write for &mut [u8]impl<'_> Read for &[u8]
Returns the mutable internal data.
Byteorder: RGBA
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
.
sourceimpl Pixmap
impl Pixmap
sourcepub fn fill_rect(
&mut self,
rect: Rect,
paint: &Paint<'_>,
transform: Transform,
clip_mask: Option<&ClipMask>
) -> Option<()>
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.
sourcepub fn fill_path(
&mut self,
path: &Path,
paint: &Paint<'_>,
fill_rule: FillRule,
transform: Transform,
clip_mask: Option<&ClipMask>
) -> Option<()>
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.
sourcepub fn stroke_path(
&mut self,
path: &Path,
paint: &Paint<'_>,
stroke: &Stroke,
transform: Transform,
clip_mask: Option<&ClipMask>
) -> Option<()>
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.
sourcepub fn draw_pixmap(
&mut self,
x: i32,
y: i32,
pixmap: PixmapRef<'_>,
paint: &PixmapPaint,
transform: Transform,
clip_mask: Option<&ClipMask>
) -> Option<()>
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
impl StructuralPartialEq for Pixmap
Auto Trait Implementations
impl RefUnwindSafe for Pixmap
impl Send for Pixmap
impl Sync for Pixmap
impl Unpin for Pixmap
impl UnwindSafe for Pixmap
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more