Crates.io | gif-dispose |
lib.rs | gif-dispose |
version | 5.0.1 |
source | src |
created_at | 2017-01-29 22:04:57.886155 |
updated_at | 2024-07-09 13:55:59.175333 |
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. |
homepage | https://lib.rs/gif-dispose |
repository | https://github.com/kornelski/image-gif-dispose.git |
max_upload_size | |
id | 8295 |
size | 18,999 |
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.
let file = 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)?;
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.