pub struct Image {
pub width: u32,
pub height: u32,
pub pixels: Vec<u8>,
}Expand description
a decoded image in RGBA format.
contains the image dimensions and raw pixel data (RGBA8 order).
use decode to load a .li file into this type.
Fields§
§width: u32image width in pixels.
height: u32image height in pixels.
pixels: Vec<u8>raw pixel data in RGBA order, width * height * 4 bytes.
Implementations§
Source§impl Image
impl Image
Sourcepub fn new(width: u32, height: u32) -> Self
pub fn new(width: u32, height: u32) -> Self
create a new blank image filled with transparent black pixels.
Sourcepub const fn contains(&self, x: u32, y: u32) -> bool
pub const fn contains(&self, x: u32, y: u32) -> bool
check if a pixel coordinate is within the image bounds.
Sourcepub fn get_pixel(&self, x: u32, y: u32) -> [u8; 4]
pub fn get_pixel(&self, x: u32, y: u32) -> [u8; 4]
get the RGBA value at a pixel coordinate.
§Panics
panics if the coordinate is out of bounds. use try_get_pixel to
handle out-of-bounds without panicking.
Sourcepub fn try_get_pixel(&self, x: u32, y: u32) -> Option<[u8; 4]>
pub fn try_get_pixel(&self, x: u32, y: u32) -> Option<[u8; 4]>
get the RGBA value at a pixel coordinate, or None if out of bounds.
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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