pub struct Pixmap {
pub width: u32,
pub height: u32,
pub samples: usize,
pub data: Vec<u8>,
}Fields§
§width: u32§height: u32§samples: usize§data: Vec<u8>Implementations§
Source§impl Pixmap
impl Pixmap
pub fn new(width: u32, height: u32, samples: usize) -> Pixmap
pub fn try_new(width: u32, height: u32, samples: usize) -> Option<Pixmap>
pub fn empty(width: u32, height: u32, samples: usize) -> Pixmap
pub fn data(&self) -> &[u8] ⓘ
pub fn data_mut(&mut self) -> &mut [u8] ⓘ
pub fn from_png<P: AsRef<Path>>(path: P) -> Result<Pixmap, Error>
Sourcepub fn from_png_bytes(bytes: &[u8]) -> Result<Pixmap, Error>
pub fn from_png_bytes(bytes: &[u8]) -> Result<Pixmap, Error>
Decode a PNG-encoded buffer into a pixmap.
Sourcepub fn to_png_bytes(&self) -> Result<Vec<u8>, Error>
pub fn to_png_bytes(&self) -> Result<Vec<u8>, Error>
Encode the pixmap as PNG bytes using the current pixel format.
Returns an error when the pixmap has no pixel data.
pub fn get_pixel(&self, x: u32, y: u32) -> Color
Trait Implementations§
Source§impl Framebuffer for Pixmap
impl Framebuffer for Pixmap
fn set_pixel(&mut self, x: u32, y: u32, color: Color)
fn set_blended_pixel(&mut self, x: u32, y: u32, color: Color, alpha: f32)
fn invert_region(&mut self, rect: &Rectangle)
fn shift_region(&mut self, rect: &Rectangle, drift: u8)
fn update(&mut self, _rect: &Rectangle, _mode: UpdateMode) -> Result<u32, Error>
fn wait(&self, _: u32) -> Result<i32, Error>
fn save(&self, path: &str) -> Result<(), Error>
fn set_rotation(&mut self, _n: i8) -> Result<(u32, u32), Error>
fn set_monochrome(&mut self, _enable: bool)
fn set_dithered(&mut self, _enable: bool)
fn set_inverted(&mut self, _enable: bool)
fn monochrome(&self) -> bool
fn dithered(&self) -> bool
fn inverted(&self) -> bool
fn width(&self) -> u32
fn height(&self) -> u32
fn toggle_inverted(&mut self)
fn toggle_monochrome(&mut self)
fn toggle_dithered(&mut self)
fn rotation(&self) -> i8
fn dims(&self) -> (u32, u32)
fn rect(&self) -> Rectangle
fn clear(&mut self, color: Color)
fn draw_rectangle(&mut self, rect: &Rectangle, color: Color)
fn draw_blended_rectangle(&mut self, rect: &Rectangle, color: Color, alpha: f32)
fn draw_rectangle_outline(&mut self, rect: &Rectangle, border: &BorderSpec)
fn draw_pixmap(&mut self, pixmap: &Pixmap, pt: Point)
fn draw_framed_pixmap(&mut self, pixmap: &Pixmap, rect: &Rectangle, pt: Point)
fn draw_framed_pixmap_contrast( &mut self, pixmap: &Pixmap, rect: &Rectangle, pt: Point, exponent: f32, gray: f32, )
fn draw_framed_pixmap_halftone( &mut self, pixmap: &Pixmap, rect: &Rectangle, pt: Point, )
fn draw_blended_pixmap(&mut self, pixmap: &Pixmap, pt: Point, color: Color)
fn draw_rounded_rectangle( &mut self, rect: &Rectangle, corners: &CornerSpec, color: Color, )
fn draw_rounded_rectangle_with_border( &mut self, rect: &Rectangle, corners: &CornerSpec, border: &BorderSpec, color: &dyn ColorSource, )
fn draw_triangle(&mut self, triangle: &[Point], color: Color)
fn draw_disk(&mut self, center: Point, radius: i32, color: Color)
fn draw_segment( &mut self, start: Point, end: Point, start_radius: f32, end_radius: f32, color: Color, )
Auto Trait Implementations§
impl Freeze for Pixmap
impl RefUnwindSafe for Pixmap
impl Send for Pixmap
impl Sync for Pixmap
impl Unpin for Pixmap
impl UnsafeUnpin 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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Converts
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Converts
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Converts
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Converts
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> DowncastSend for T
impl<T> DowncastSend for T
§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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>
Converts
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>
Converts
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