Struct gif::DecodeOptions
source · pub struct DecodeOptions {
memory_limit: MemoryLimit,
color_output: ColorOutput,
check_frame_consistency: bool,
skip_frame_decoding: bool,
check_for_end_code: bool,
allow_unknown_blocks: bool,
}
Expand description
Options for opening a GIF decoder. DecodeOptions::read_info
will start the decoder.
Fields§
§memory_limit: MemoryLimit
§color_output: ColorOutput
§check_frame_consistency: bool
§skip_frame_decoding: bool
§check_for_end_code: bool
§allow_unknown_blocks: bool
Implementations§
source§impl DecodeOptions
impl DecodeOptions
sourcepub fn new() -> DecodeOptions
pub fn new() -> DecodeOptions
Creates a new decoder builder
sourcepub fn set_color_output(&mut self, color: ColorOutput)
pub fn set_color_output(&mut self, color: ColorOutput)
Configure how color data is decoded.
sourcepub fn set_memory_limit(&mut self, limit: MemoryLimit)
pub fn set_memory_limit(&mut self, limit: MemoryLimit)
Configure a memory limit for decoding.
sourcepub fn check_frame_consistency(&mut self, check: bool)
pub fn check_frame_consistency(&mut self, check: bool)
Configure if frames must be within the screen descriptor.
The default is false
.
When turned on, all frame descriptors being read must fit within the screen descriptor or otherwise an error is returned and the stream left in an unspecified state.
When turned off, frames may be arbitrarily larger or offset in relation to the screen. Many other decoder libraries handle this in highly divergent ways. This moves all checks to the caller, for example to emulate a specific style.
sourcepub fn skip_frame_decoding(&mut self, skip: bool)
pub fn skip_frame_decoding(&mut self, skip: bool)
Configure whether to skip decoding frames.
The default is false.
When turned on, LZW decoding is skipped. Decoder::read_next_frame
will return
compressed LZW bytes in frame’s data.
Decoder::next_frame_info
will return the metadata of the next frame as usual.
This is useful to count frames without incurring the overhead of decoding.
sourcepub fn check_lzw_end_code(&mut self, check: bool)
pub fn check_lzw_end_code(&mut self, check: bool)
Configure if LZW encoded blocks must end with a marker end code.
The default is false
.
When turned on, all image data blocks—which are LZW encoded—must contain a special bit sequence signalling the end of the data. LZW processing terminates when this code is encountered. The specification states that it must be the last code output by the encoder for an image.
When turned off then image data blocks can simply end. Note that this might silently ignore some bits of the last or second to last byte.
sourcepub fn allow_unknown_blocks(&mut self, check: bool)
pub fn allow_unknown_blocks(&mut self, check: bool)
Configure if unknown blocks are allowed to be decoded.
The default is false
.
When turned on, the decoder will allow unknown blocks to be in the
BlockStart
position.
When turned off, decoded block starts must mark an Image
, Extension
,
or Trailer
block. Otherwise, the decoded image will return an error.
If an unknown block error is returned from decoding, enabling this
setting may allow for a further state of decoding on the next attempt.
Trait Implementations§
source§impl Clone for DecodeOptions
impl Clone for DecodeOptions
source§fn clone(&self) -> DecodeOptions
fn clone(&self) -> DecodeOptions
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for DecodeOptions
impl Debug for DecodeOptions
Auto Trait Implementations§
impl Freeze for DecodeOptions
impl RefUnwindSafe for DecodeOptions
impl Send for DecodeOptions
impl Sync for DecodeOptions
impl Unpin for DecodeOptions
impl UnwindSafe for DecodeOptions
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)