#decoder #encoder

flic

Autodesk Animator FLI and Autodesk Animator Pro FLC file encoder and decoder

7 releases

0.1.6 Jul 22, 2017
0.1.5 Apr 29, 2017
0.1.4 Feb 3, 2017
0.1.2 Jan 21, 2017
0.1.0 Oct 23, 2016

#14 in Video

Download history 1/week @ 2019-11-09 24/week @ 2019-11-16 7/week @ 2019-11-23 7/week @ 2019-11-30 79/week @ 2019-12-07 71/week @ 2019-12-14 1/week @ 2019-12-21 7/week @ 2019-12-28 1/week @ 2020-01-04 67/week @ 2020-01-11 98/week @ 2020-01-18 7/week @ 2020-01-25 4/week @ 2020-02-01 10/week @ 2020-02-08 27/week @ 2020-02-15

92 downloads per month
Used in 2 crates

MIT license

175KB
4K SLoC

LibFLIC Version Status

About

LibFLIC provides routines for encoding and decoding Autodesk Animator FLI and Autodesk Animator Pro FLC files.

The code is based on the documentation and source code of Animator and Animator Pro that has been released by Jim Kent.

LibFLIC is written entirely in Rust. C bindings to the underlying codecs are provided.

Examples

A few example programs are provided in the examples/ directory:

  • quickfli - a simple FLIC player.
  • recompress - loads and saves FLIC files.
  • browse - display postage stamps (thumbnails).

To clone this repository, run:

git clone https://github.com/wangds/libflic.git

Then build the library and run the example programs using Cargo.

cargo build --example quickfli

To play a FLIC file, run:

cargo run --example quickfli <example.flc>

Basic Usage

Add LibFLIC as a dependency to your project's Cargo.toml:

[dependencies]
flic = "0.1"

Import the library in your project, e.g.:

extern crate flic;

use flic::{FlicFile,RasterMut};

The FlicFile type refers to FLIC files streamed from disk. When opening a FLIC file, it will first read the FLIC metadata such as the animation's dimensions and speed. FlicFile will keep the file open.

let flic = FlicFile::open(Path::new("example.flc"))?;

Allocate the pixel data and palette data buffers to which we will decode the animation.

let flic_w = flic.width() as usize;
let flic_h = flic.height() as usize;
let mut buf = vec![0; flic_w * flic_h];
let mut pal = vec![0; 3 * 256];

It is convenient to group these two buffers, along with their dimensions and strides, together to form a single Raster or RasterMut type.

LibFLIC will ask for a Raster type for operations that require read-only access to the buffers (e.g. encoding), and a RasterMut type when it requires read-write access (e.g. decoding).

For example, to decode a frame, we first create a RasterMut by borrowing buf and pal mutably as shown below. Rasters are cheap to create, so don't worry about creating and dropping them frequently.

let mut raster = RasterMut::new(flic_w, flic_h, &mut buf, &mut pal);
flic.read_next_frame(&mut raster);

Since FLIC files store the differences between consecutive frames, when reading the next frame in the animation, it is up to the library user to ensure that the buffer and palettes contain the previous frame's data.

Documentation

Author

David Wang

Dependencies

~170KB