ImageData

Struct ImageData 

Source
pub struct ImageData<'a> { /* private fields */ }
Expand description

image data

Implementations§

Source§

impl ImageData<'_>

Source

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

get pixel values encoded as bytes.

this is guaranteed to be a prefix of the buffer passed to decode_png.

Source

pub fn palette(&self, index: u8) -> [u8; 4]

get color in palette at index.

returns [0, 0, 0, 255] if index is out of range.

Source

pub fn width(&self) -> u32

image width in pixels

Source

pub fn height(&self) -> u32

image height in pixels

Source

pub fn bit_depth(&self) -> BitDepth

bits per sample of image

Source

pub fn color_type(&self) -> ColorType

number and type of color channels

Source

pub fn bytes_per_row(&self) -> usize

number of bytes in a single row of pixels

Source

pub fn convert_to_rgba8bpc(&mut self) -> Result<()>

convert self to 8-bits-per-channel RGBA

note: this function can fail with Error::BufferTooSmall if the buffer you allocated is too small! make sure to use ImageHeader::required_bytes_rgba8bpc for this.

Trait Implementations§

Source§

impl<'a> Debug for ImageData<'a>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for ImageData<'a>

§

impl<'a> RefUnwindSafe for ImageData<'a>

§

impl<'a> Send for ImageData<'a>

§

impl<'a> Sync for ImageData<'a>

§

impl<'a> Unpin for ImageData<'a>

§

impl<'a> !UnwindSafe for ImageData<'a>

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.