pub struct Image {
pub bytes: Vec<u8>,
pub width: u16,
pub height: u16,
}Expand description
Image, data stored in CPU memory
Fields§
§bytes: Vec<u8>§width: u16§height: u16Implementations§
Source§impl Image
impl Image
Sourcepub fn from_file_with_format(
bytes: &[u8],
format: Option<ImageFormat>,
) -> Result<Image, Error>
pub fn from_file_with_format( bytes: &[u8], format: Option<ImageFormat>, ) -> Result<Image, Error>
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 blend(&mut self, other: &Image)
pub fn blend(&mut self, other: &Image)
Blends this image with another image (of identical dimensions) Inspired by OpenCV saturated blending
Sourcepub fn overlay(&mut self, other: &Image)
pub fn overlay(&mut self, other: &Image)
Overlays an image on top of this one. Slightly different from blending two images, overlaying a completely transparent image has no effect on the original image, though blending them would.
Sourcepub fn export_png(&self, path: &str)
pub fn export_png(&self, path: &str)
Saves this image as a PNG file. This method is not supported on web and will panic.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Image
impl RefUnwindSafe for Image
impl Send for Image
impl Sync for Image
impl Unpin for Image
impl UnsafeUnpin for Image
impl UnwindSafe for Image
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