pub struct Image { /* private fields */ }Expand description
An image that can be displayed by the runtime.
Internally stores data as an array of 32 bit RGBA values.
Implementations§
Source§impl Image
impl Image
Sourcepub fn new(width: i32, height: i32, color: Color) -> Self
pub fn new(width: i32, height: i32, color: Color) -> Self
Create a blank image
§Arguments
width- the number of horizontal pixelsheight- the number of vertical pixels.color- the initial color of all pixels in the image.
Sourcepub fn from_data(width: i32, height: i32, data: &[u8]) -> Self
pub fn from_data(width: i32, height: i32, data: &[u8]) -> Self
Create an image from a slice of existing data
§Arguments
width- the number of horizontal pixelsheight- the number of vertical pixelsdata- slice of existing data.
Sourcepub fn set_pixel(&mut self, x: i32, y: i32, color: Color)
pub fn set_pixel(&mut self, x: i32, y: i32, color: Color)
Sets a pixel in the image to a specified color
§Arguments
x- horizontal coordinatey- vertical coordinatecolor- color to set the pixel to
Sourcepub fn pixels_mut(&mut self) -> &mut [u32]
pub fn pixels_mut(&mut self) -> &mut [u32]
Gets a mutable reference to the raw pixel buffer
Sourcepub fn pixels8_mut(&mut self) -> &mut [u8] ⓘ
pub fn pixels8_mut(&mut self) -> &mut [u8] ⓘ
Gets a mutable reference to the raw pixel buffer as u8s
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Image
impl<'de> Deserialize<'de> for Image
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for Image
impl RefUnwindSafe for Image
impl Send for Image
impl Sync for Image
impl Unpin 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