#gif #frames #animation

gif-dispose

Implements GIF disposal method for the gif crate. The gif crate only exposes raw frame data that is not sufficient to render GIFs properly. GIF requires special composing of frames which, as this crate shows, is non-trivial.

11 stable releases

✓ Uses Rust 2018 edition

new 2.4.1 Jul 6, 2020
2.3.0 Apr 6, 2020
2.2.0 Mar 16, 2019
2.1.1 Jun 5, 2018
1.0.1 Mar 1, 2017

#5 in Video

Download history 296/week @ 2020-03-16 558/week @ 2020-03-23 716/week @ 2020-03-30 778/week @ 2020-04-06 687/week @ 2020-04-13 533/week @ 2020-04-20 701/week @ 2020-04-27 631/week @ 2020-05-04 665/week @ 2020-05-11 662/week @ 2020-05-18 599/week @ 2020-05-25 763/week @ 2020-06-01 782/week @ 2020-06-08 659/week @ 2020-06-15 664/week @ 2020-06-22 490/week @ 2020-06-29

2,814 downloads per month
Used in 8 crates (6 directly)

MIT/Apache

10KB
131 lines

Please dispose of GIF frames properly

This crate implements GIF disposal method for the gif crate.

The gif crate only exposes raw frame data that is not sufficient to render animated GIFs properly. GIF requires special composing of frames which is non-trivial.

Usage

let file = File::open("example.gif")?;
let mut decoder = Decoder::new(file);

// Important:
decoder.set(gif::ColorOutput::Indexed);

let mut reader = decoder.read_info()?;

let mut screen = Screen::new_reader(&reader);
while let Some(frame) = reader.read_next_frame()? {
    screen.blit_frame(&frame)?;
    screen.pixels // that's the frame now in RGBA format
}

The screen.pixels buffer uses ImgVec to represent a 2D image.

See examples/explode.rs for more.

Requirements

  • Latest stable Rust (1.42+)

lib.rs:

Implements GIF disposal method for the gif crate.

The gif crate only exposes raw frame data that is not sufficient to render GIFs properly. GIF requires special composing of frames which, as this crate shows, is non-trivial.

let file = File::open("example.gif")?;
let mut decoder = Decoder::new(file);

// Important:
decoder.set(gif::ColorOutput::Indexed);

let mut reader = decoder.read_info()?;

let mut screen = Screen::new_reader(&reader);
while let Some(frame) = reader.read_next_frame()? {
    screen.blit_frame(&frame)?;
    screen.pixels // that's the frame now
}

Dependencies

~250KB