GIF en- and decoding library
GIF en- and decoder written in Rust (API Documentation).
GIF encoding and decoding library
This library provides all functions necessary to de- and encode GIF files.
High level interface
The high level interface consists of the two types
Encoder
and Decoder
.
Decoding GIF files
// Open the file
use File;
let input = open.unwrap;
// Configure the decoder such that it will expand the image to RGBA.
let mut options = new;
options.set_color_output;
// Read the file header
let mut decoder = options.read_info.unwrap;
while let Some = decoder.read_next_frame.unwrap
Encoding GIF files
The encoder can be used to save simple computer generated images:
use ;
use File;
use Cow;
let color_map = &;
let = ;
let beacon_states = ;
let mut image = create.unwrap;
let mut encoder = new.unwrap;
encoder.set_repeat.unwrap;
for state in &beacon_states
Frame::from_*
can be used to convert a true color image to a paletted
image with a maximum of 256 colors:
use File;
// Get pixel data from some source
let mut pixels: = vec!;
// Create frame from data
let frame = from_rgb;
// Create encoder
let mut image = create.unwrap;
let mut encoder = new.unwrap;
// Write frame to file
encoder.write_frame.unwrap;