https://github.com/kornelski/image-gif-dispose
Implements GIF disposal method (full rendering of frames) for the Rust gif crate
https://github.com/kornelski/image-gif-dispose
animated-gif frames gif gif-disposal gif-library
Last synced: about 2 months ago
JSON representation
Implements GIF disposal method (full rendering of frames) for the Rust gif crate
- Host: GitHub
- URL: https://github.com/kornelski/image-gif-dispose
- Owner: kornelski
- Created: 2017-01-29T21:57:34.000Z (almost 9 years ago)
- Default Branch: main
- Last Pushed: 2024-04-06T18:16:56.000Z (over 1 year ago)
- Last Synced: 2024-04-14T13:51:53.315Z (over 1 year ago)
- Topics: animated-gif, frames, gif, gif-disposal, gif-library
- Language: Rust
- Homepage: https://lib.rs/gif-dispose
- Size: 37.1 KB
- Stars: 19
- Watchers: 6
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## Please dispose of GIF frames properly
This crate implements GIF disposal method for the [gif crate](https://lib.rs/crates/gif).
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
```rust
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](https://lib.rs/crates/imgref) to represent a 2D image.
See `examples/explode.rs` for more.
## Requirements
* Latest stable Rust (1.45+)