pub trait Bitmap: Clone {
// Required methods
fn new(size: Size<i32>, color: Color) -> Self;
fn size(&self) -> Size<i32>;
fn width(&self) -> i32;
fn height(&self) -> i32;
fn pixel(&self, point: Point<i32>) -> Color;
fn set_pixel(&mut self, point: Point<i32>, color: Color);
fn bytes(&self) -> &[u8] ⓘ;
fn from_parts(size: Size<i32>, bytes: &[u8]) -> Self;
fn set_from(&mut self, other: &Self);
// Provided methods
fn png_bytes(&self) -> Result<Vec<u8>> { ... }
fn try_from_file_bytes(bytes: Vec<u8>) -> Result<Self> { ... }
}
Expand description
Represents a 2D matrix of pixels (an image)
Required Methods§
Sourcefn new(size: Size<i32>, color: Color) -> Self
fn new(size: Size<i32>, color: Color) -> Self
Create a new image with a specified size and filled with one color
Sourcefn set_pixel(&mut self, point: Point<i32>, color: Color)
fn set_pixel(&mut self, point: Point<i32>, color: Color)
Set the pixel at a certain Point
to a specified color
Provided Methods§
Sourcefn png_bytes(&self) -> Result<Vec<u8>>
fn png_bytes(&self) -> Result<Vec<u8>>
Get the the PNG representation of this image as a sequence of bytes
Sourcefn try_from_file_bytes(bytes: Vec<u8>) -> Result<Self>
fn try_from_file_bytes(bytes: Vec<u8>) -> Result<Self>
Create a new image from a sequence of bytes read from an image file (e.g. PNG or JPG)
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.