Crate gif_dispose

Crate gif_dispose 

Source
Expand description

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 = std::fs::File::open("example.gif")?;

let mut gif_opts = gif::DecodeOptions::new();
// Important:
gif_opts.set_color_output(gif::ColorOutput::Indexed);

let mut decoder = gif_opts.read_info(file)?;
let mut screen = gif_dispose::Screen::new_decoder(&decoder);

while let Some(frame) = decoder.read_next_frame()? {
    screen.blit_frame(&frame)?;
    let _ = screen.pixels_rgba().clone(); // that's the frame now in RGBA format
    let _ = screen.pixels_rgba().to_contiguous_buf(); // that works too
}

Structs§

Screen
Combined GIF frames forming a “virtual screen”. See Screen::new_decoder.
TempDisposedStateScreen
Screen that has a temporary state between frames

Enums§

Error

Type Aliases§

ImgRef
Reference to pixels inside another image. Pass this structure by value (i.e. ImgRef, not &ImgRef).
RGB8
8-bit RGB
RGBA8
8-bit RGBA, alpha is last. 0 = transparent, 255 = opaque.