Struct png::Reader

source ·
pub struct Reader<R: Read> { /* private fields */ }
Expand description

PNG reader (mostly high-level interface)

Provides a high level that iterates over lines or whole images.

Implementations§

source§

impl<R: Read> Reader<R>

source

pub fn info(&self) -> &Info<'_>

Get information on the image.

The structure will change as new frames of an animated image are decoded.

source

pub fn next_frame( &mut self, buf: &mut [u8] ) -> Result<OutputInfo, DecodingError>

Decodes the next frame into buf.

Note that this decodes raw subframes that need to be mixed according to blend-op and dispose-op by the caller.

The caller must always provide a buffer large enough to hold a complete frame (the APNG specification restricts subframes to the dimensions given in the image header). The region that has been written be checked afterwards by calling info after a successful call and inspecting the frame_control data. This requirement may be lifted in a later version of png.

Output lines will be written in row-major, packed matrix with width and height of the read frame (or subframe), all samples are in big endian byte order where this matters.

source

pub fn next_row(&mut self) -> Result<Option<Row<'_>>, DecodingError>

Returns the next processed row of the image

source

pub fn next_interlaced_row( &mut self ) -> Result<Option<InterlacedRow<'_>>, DecodingError>

Returns the next processed row of the image

source

pub fn output_color_type(&self) -> (ColorType, BitDepth)

Returns the color type and the number of bits per sample of the data returned by Reader::next_row and Reader::frames`.

source

pub fn output_buffer_size(&self) -> usize

Returns the number of bytes required to hold a deinterlaced image frame that is decoded using the given input transformations.

source

pub fn output_line_size(&self, width: u32) -> usize

Returns the number of bytes required to hold a deinterlaced row.

Auto Trait Implementations§

§

impl<R> RefUnwindSafe for Reader<R>where R: RefUnwindSafe,

§

impl<R> Send for Reader<R>where R: Send,

§

impl<R> Sync for Reader<R>where R: Sync,

§

impl<R> Unpin for Reader<R>where R: Unpin,

§

impl<R> UnwindSafe for Reader<R>where R: UnwindSafe,

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

const: unstable · source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

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

const: unstable · 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 Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.
source§

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

§

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

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.