Expand description
Image, data stored in CPU memory
Fields
bytes: Vec<u8>
width: u16
height: u16
Implementations
sourceimpl Image
impl Image
sourcepub fn from_file_with_format(bytes: &[u8], format: Option<ImageFormat>) -> Image
pub fn from_file_with_format(bytes: &[u8], format: Option<ImageFormat>) -> Image
Creates an Image from a slice of bytes that contains an encoded image.
If format
is None, it will make an educated guess on the
ImageFormat.
Example
let icon = Image::from_file_with_format(
include_bytes!("../examples/rust.png"),
Some(ImageFormat::Png),
);
sourcepub fn gen_image_color(width: u16, height: u16, color: Color) -> Image
pub fn gen_image_color(width: u16, height: u16, color: Color) -> Image
Creates an Image filled with the provided Color.
sourcepub fn get_image_data(&self) -> &[[u8; 4]]
pub fn get_image_data(&self) -> &[[u8; 4]]
Returns this image’s data as a slice of 4-byte arrays.
sourcepub fn get_image_data_mut(&mut self) -> &mut [[u8; 4]]
pub fn get_image_data_mut(&mut self) -> &mut [[u8; 4]]
Returns this image’s data as a mutable slice of 4-byte arrays.
sourcepub fn set_pixel(&mut self, x: u32, y: u32, color: Color)
pub fn set_pixel(&mut self, x: u32, y: u32, color: Color)
Modifies a pixel Color in this image.
sourcepub fn export_png(&self, path: &str)
pub fn export_png(&self, path: &str)
Saves this image as a PNG file.
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for Image
impl Send for Image
impl Sync for Image
impl Unpin for Image
impl UnwindSafe for Image
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