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>
impl<R: Read> Reader<R>
sourcepub fn info(&self) -> &Info<'static>
pub fn info(&self) -> &Info<'static>
Get information on the image.
The structure will change as new frames of an animated image are decoded.
sourcepub fn next_frame(
&mut self,
buf: &mut [u8],
) -> Result<OutputInfo, DecodingError>
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.
sourcepub fn next_row(&mut self) -> Result<Option<Row<'_>>, DecodingError>
pub fn next_row(&mut self) -> Result<Option<Row<'_>>, DecodingError>
Returns the next processed row of the image
sourcepub fn next_interlaced_row(
&mut self,
) -> Result<Option<InterlacedRow<'_>>, DecodingError>
pub fn next_interlaced_row( &mut self, ) -> Result<Option<InterlacedRow<'_>>, DecodingError>
Returns the next processed row of the image
sourcepub fn finish(&mut self) -> Result<(), DecodingError>
pub fn finish(&mut self) -> Result<(), DecodingError>
Read the rest of the image and chunks and finish up, including text chunks or others
This will discard the rest of the image if the image is not read already with Reader::next_frame
, Reader::next_row
or Reader::next_interlaced_row
sourcepub fn output_color_type(&self) -> (ColorType, BitDepth)
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`.
sourcepub fn output_buffer_size(&self) -> usize
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.
sourcepub fn output_line_size(&self, width: u32) -> usize
pub fn output_line_size(&self, width: u32) -> usize
Returns the number of bytes required to hold a deinterlaced row.