Skip to main content

GifDecoder

Struct GifDecoder 

Source
pub struct GifDecoder { /* private fields */ }
Expand description

Pure-Rust GIF87a/GIF89a container parser and indexed LZW frame decoder.

Implementations§

Source§

impl GifDecoder

GIF87a/GIF89a container parsing and true LZW pixel decompression for GifDecoder.

Source

pub fn parse(bytes: &[u8]) -> Result<Self, String>

Parses a GIF87a/GIF89a byte stream into lightweight frame descriptors using default GifDecodeConfig.

§Arguments
  • &[u8] - Raw .gif file bytes.
§Returns
  • Result<Self, String> - Parsed GIF decoder or structural/budget error.
Source

pub fn parse_with_config( bytes: &[u8], config: GifDecodeConfig, ) -> Result<Self, String>

Parses a GIF87a/GIF89a byte stream validating header, palettes, GCEs, Netscape loop count, and sub-block bounds.

§Arguments
  • &[u8] - Raw .gif file bytes.
  • GifDecodeConfig - Memory budget and frame-delay compatibility policy.
§Returns
  • Result<Self, String> - Parsed GIF decoder or error.
Source

pub fn get_bytes(&self) -> &[u8] ⓘ

Returns a zero-copy borrowed slice over the backing encoded GIF stream bytes.

§Arguments
  • &Self - GIF decoder reference.
§Returns
  • &[u8] - Backing GIF byte stream.
Source

pub fn normalize_delay_ms(delay_cs: u16, config: &GifDecodeConfig) -> u32

Normalizes a GIF89a centisecond frame delay according to GifDecodeConfig.

§Arguments
  • u16 - Raw delay in 1/100 s centiseconds.
  • &GifDecodeConfig - Compatibility policy.
§Returns
  • u32 - Effective millisecond frame delay.
Source

pub fn decode_lzw_subblocks( subblocks: &[u8], min_code_size: u8, expected_pixels: usize, out_indices: &mut Vec<u8>, ) -> Result<(), String>

Decompresses variable-width GIF LZW sub-blocks directly into out_indices without copying sub-blocks.

§Arguments
  • &[u8] - Raw sub-block byte slice starting at the first sub-block length byte.
  • u8 - Initial LZW minimum code size (2..=8).
  • usize - Expected pixel index count (frame_width * frame_height).
  • &mut Vec<u8> - Reusable destination palette-index vector cleared and populated in place.
§Returns
  • Result<(), String> - Ok(()) on exact decompression, or Err on corrupt/truncated LZW data.
Source

pub fn deinterlace_row(src_row: usize, height: usize) -> usize

Maps an interlaced decoded row index src_row to its visual canvas row inside 0..height.

§Arguments
  • usize - Decoded row index in stream order.
  • usize - Frame height in pixels.
§Returns
  • usize - Target visual row index inside 0..height.
Source

pub fn lookup_rgb(&self, desc: &GifFrameDescriptor, color_idx: u8) -> [u8; 3]

Resolves RGB color for palette index color_idx against the frame’s Local Color Table or fallback Global Color Table.

§Arguments
  • &Self - GIF decoder reference.
  • &GifFrameDescriptor - Active frame descriptor.
  • u8 - Palette index.
§Returns
  • [u8; 3] - Resolved [r, g, b] color triplet ([0, 0, 0] if out of palette bounds).
Source

pub fn decode_all_animation(&self, title: &str) -> Result<GifAnimation, String>

Decodes all frames in sequence into a GifAnimation using a single reusable composite canvas.

§Arguments
  • &Self - GIF decoder reference.
  • &str - Asset title.
§Returns
  • Result<GifAnimation, String> - Fully decoded GifAnimation with exact source dimensions and composited RGBA8 frames.
Source§

impl GifDecoder

Source

pub fn get_version(&self) -> &String

Source

pub fn get_mut_version(&mut self) -> &mut String

Source

pub fn set_version(&mut self, val: String) -> &mut Self

Source

pub fn get_logical_width(&self) -> u16

Source

pub fn get_mut_logical_width(&mut self) -> &mut u16

Source

pub fn set_logical_width(&mut self, val: u16) -> &mut Self

Source

pub fn get_logical_height(&self) -> u16

Source

pub fn get_mut_logical_height(&mut self) -> &mut u16

Source

pub fn set_logical_height(&mut self, val: u16) -> &mut Self

Source

pub fn get_background_color_index(&self) -> u8

Source

pub fn get_mut_background_color_index(&mut self) -> &mut u8

Source

pub fn set_background_color_index(&mut self, val: u8) -> &mut Self

Source

pub fn get_global_color_table(&self) -> &Vec<[u8; 3]>

Source

pub fn get_mut_global_color_table(&mut self) -> &mut Vec<[u8; 3]>

Source

pub fn set_global_color_table(&mut self, val: Vec<[u8; 3]>) -> &mut Self

Source

pub fn get_has_netscape_loop(&self) -> bool

Source

pub fn get_mut_has_netscape_loop(&mut self) -> &mut bool

Source

pub fn set_has_netscape_loop(&mut self, val: bool) -> &mut Self

Source

pub fn get_loop_count(&self) -> u32

Source

pub fn get_mut_loop_count(&mut self) -> &mut u32

Source

pub fn set_loop_count(&mut self, val: u32) -> &mut Self

Source

pub fn get_frames(&self) -> &Vec<GifFrameDescriptor>

Source

pub fn get_mut_frames(&mut self) -> &mut Vec<GifFrameDescriptor>

Source

pub fn set_frames(&mut self, val: Vec<GifFrameDescriptor>) -> &mut Self

Source

pub fn get_config(&self) -> GifDecodeConfig

Source

pub fn get_mut_config(&mut self) -> &mut GifDecodeConfig

Source

pub fn set_config(&mut self, val: GifDecodeConfig) -> &mut Self

Trait Implementations§

Source§

impl Clone for GifDecoder

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for GifDecoder

Source§

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

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

impl Default for GifDecoder

Source§

fn default() -> Self

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

Auto Trait Implementations§

§

impl Forget for GifDecoder

§

impl Freeze for GifDecoder
where *const ArcInner<[u8]> is !null: Freeze, PhantomData<ArcInner<[u8]>>: Freeze, *const u8 is !null: Freeze, PhantomData<u8>: Freeze, PhantomData<[u8; 3]>: Freeze, PhantomData<GifFrameDescriptor>: Freeze,

§

impl Move for GifDecoder

§

impl RefUnwindSafe for GifDecoder

§

impl Send for GifDecoder
where Arc<[u8]>: Send, RawVecInner: Send,

§

impl Sync for GifDecoder
where Arc<[u8]>: Sync, RawVecInner: Sync,

§

impl Unpin for GifDecoder
where Arc<[u8]>: Unpin, *const u8 is !null: Unpin,

§

impl UnsafeUnpin for GifDecoder

§

impl UnwindSafe for GifDecoder
where Arc<[u8]>: UnwindSafe, RawVecInner: UnwindSafe,

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, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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 = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.