Image

Struct Image 

Source
pub struct Image { /* private fields */ }
Expand description

An image loaded from a file.

Implementations§

Source§

impl Image

Source

pub fn width(&self) -> u32

Source

pub fn height(&self) -> u32

Source

pub fn data(&self) -> &[u8]

Gets the image data as a slice of bytes, each byte representing a pixel indexed by the image’s palette.

Source

pub fn data_mut(&mut self) -> &mut [u8]

Gets the image data as a mutable slice of bytes, each byte representing a pixel indexed by the image’s palette.

Source

pub fn palette_count(&self) -> u32

Gets the number of pixel colors in the palette. The full size of the palette is palette_count * 3 bytes.

Source

pub fn palette(&self) -> &[u8]

Gets the image’s color palette as a slice of bytes, in RGB (8 bits per channel).

Source

pub fn palette_mut(&mut self) -> &mut [u8]

Gets the image’s color palette as a mutable slice of bytes, in RGB (8 bits per channel).

Source

pub fn raw_palette(&self) -> &[u8; 768]

Gets the image’s color palette as a reference to the underlying array, in RGB (8 bits per channel).

The maximum expected size of any palette is 768 bytes (256 colors * 3 bytes per color). Note that the real palette used might be smaller than the full size of the array, see palette for an accurate slice.

Trait Implementations§

Source§

impl Debug for Image

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Send for Image

Source§

impl Sync for Image

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.