pub struct Image {
pub width: u32,
pub height: u32,
pub data: Vec<u8>,
}Expand description
8-bit sRGB RGBA, straight alpha, row-major, no padding.
Fields§
§width: u32Width in pixels.
height: u32Height in pixels.
data: Vec<u8>width * height * 4 bytes.
Implementations§
Source§impl Image
impl Image
Sourcepub fn encode_png(&self) -> Vec<u8> ⓘ
pub fn encode_png(&self) -> Vec<u8> ⓘ
Encodes the image as PNG (8-bit RGBA, straight alpha).
§Panics
If data is not width * height * 4 bytes — a bug in whoever
built the image.
Sourcepub fn decode_png(bytes: &[u8]) -> Option<Image>
pub fn decode_png(bytes: &[u8]) -> Option<Image>
Reads an 8-bit RGBA or RGB PNG, such as one encode_png
wrote. None for anything else or a broken file.
Trait Implementations§
impl Eq for Image
impl StructuralPartialEq for Image
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