pub struct Decoder<R: Read> {
decoder: ReadDecoder<R>,
pixel_converter: PixelConverter,
bg_color: Option<u8>,
repeat: Repeat,
current_frame: Frame<'static>,
current_frame_data_type: FrameDataType,
}
Expand description
GIF decoder. Create DecodeOptions
to get started, and call DecodeOptions::read_info
.
Fields§
§decoder: ReadDecoder<R>
§pixel_converter: PixelConverter
§bg_color: Option<u8>
§repeat: Repeat
§current_frame: Frame<'static>
§current_frame_data_type: FrameDataType
Implementations§
source§impl<R> Decoder<R>where
R: Read,
impl<R> Decoder<R>where
R: Read,
sourcepub fn new(reader: R) -> Result<Self, DecodingError>
pub fn new(reader: R) -> Result<Self, DecodingError>
Create a new decoder with default options.
sourcepub fn build() -> DecodeOptions
pub fn build() -> DecodeOptions
Return a builder that allows configuring limits etc.
fn with_no_init( reader: R, decoder: StreamingDecoder, options: DecodeOptions, ) -> Decoder<R>
fn init(self) -> Result<Self, DecodingError>
sourcepub fn next_frame_info(
&mut self,
) -> Result<Option<&Frame<'static>>, DecodingError>
pub fn next_frame_info( &mut self, ) -> Result<Option<&Frame<'static>>, DecodingError>
Returns the next frame info
sourcepub fn read_next_frame(
&mut self,
) -> Result<Option<&Frame<'static>>, DecodingError>
pub fn read_next_frame( &mut self, ) -> Result<Option<&Frame<'static>>, DecodingError>
Reads the next frame from the image.
Do not call Self::next_frame_info
beforehand.
Deinterlaces the result.
You can also call .into_iter()
on the decoder to use it as a regular iterator.
sourcefn take_current_frame(&mut self) -> Option<Frame<'static>>
fn take_current_frame(&mut self) -> Option<Frame<'static>>
This is private for iterator’s use
sourcepub fn read_into_buffer(&mut self, buf: &mut [u8]) -> Result<(), DecodingError>
pub fn read_into_buffer(&mut self, buf: &mut [u8]) -> Result<(), DecodingError>
Reads the data of the current frame into a pre-allocated buffer.
Self::next_frame_info
needs to be called beforehand.
The length of buf
must be at least Self::buffer_size
.
Deinterlaces the result.
fn copy_lzw_into_buffer( &mut self, min_code_size: u8, buf: &mut Vec<u8>, ) -> Result<(), DecodingError>
sourcepub fn fill_buffer(&mut self, buf: &mut [u8]) -> Result<bool, DecodingError>
pub fn fill_buffer(&mut self, buf: &mut [u8]) -> Result<bool, DecodingError>
Reads data of the current frame into a pre-allocated buffer until the buffer has been filled completely.
The buffer length must be an even number of pixels (multiple of 4 if decoding RGBA).
Self::next_frame_info
needs to be called beforehand. Returns true
if the supplied
buffer could be filled completely. Should not be called after false
had been returned.
sourcepub fn buffer_size(&self) -> usize
pub fn buffer_size(&self) -> usize
Output buffer size
sourcepub fn line_length(&self) -> usize
pub fn line_length(&self) -> usize
Line length of the current frame
sourcepub fn palette(&self) -> Result<&[u8], DecodingError>
pub fn palette(&self) -> Result<&[u8], DecodingError>
Returns the color palette relevant for the frame that has been decoded
sourcepub fn global_palette(&self) -> Option<&[u8]>
pub fn global_palette(&self) -> Option<&[u8]>
The global color palette
sourcepub fn into_inner(self) -> BufReader<R>
pub fn into_inner(self) -> BufReader<R>
Abort decoding and recover the io::Read
instance