#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.

7 stable releases

2.1.1 Jun 5, 2018
2.1.0 Nov 27, 2017
2.0.0 Oct 27, 2017
1.0.2 Jul 17, 2017
1.0.0 Jan 29, 2017

#7 in Video

Download history 63/week @ 2018-07-06 140/week @ 2018-07-13 94/week @ 2018-07-20 142/week @ 2018-07-27 112/week @ 2018-08-03 264/week @ 2018-08-10 152/week @ 2018-08-17 104/week @ 2018-08-24 105/week @ 2018-08-31 144/week @ 2018-09-07 196/week @ 2018-09-14 102/week @ 2018-09-21 185/week @ 2018-09-28

266 downloads per month
Used in 5 crates (4 directly)

MIT/Apache

11KB
182 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 GIFs properly. GIF requires special composing of frames which 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 in RGBA format
}

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)?;
    screen.pixels // that's the frame now
}

Dependencies

~217KB