Struct gif::reader::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

source

pub fn new() -> DecodeOptions

Creates a new decoder builder

source

pub fn set_color_output(&mut self, color: ColorOutput)

Configure how color data is decoded.

source

pub fn set_memory_limit(&mut self, limit: MemoryLimit)

Configure a memory limit for decoding.

source

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.

source

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.

source

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.

source

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.

source

pub fn read_info<R: Read>(self, r: R) -> Result<Decoder<R>, DecodingError>

Reads the logical screen descriptor including the global color palette

Returns a Decoder. All decoder configuration has to be done beforehand.

Trait Implementations§

source§

impl Clone for DecodeOptions

source§

fn clone(&self) -> DecodeOptions

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for DecodeOptions

source§

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

Formats the value using the given formatter. Read more
source§

impl Default for DecodeOptions

source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. 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> ToOwned for T
where T: Clone,

source§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.