Struct flic::flic::FlicFileWriter [] [src]

pub struct FlicFileWriter { /* fields omitted */ }

FLIC animation writer, with a File handle.

Opens and holds onto the file handle until it is closed.

Methods

impl FlicFileWriter
[src]

Open a file for writing Animator Pro FLCs.

Examples

use std::path::Path;

const SCREEN_W: u16 = 320;
const SCREEN_H: u16 = 200;
const speed_msec: u32 = 70;

flic::FlicFileWriter::create(Path::new("ex.flc"), SCREEN_W, SCREEN_H, speed_msec);

Open a file for writing Animator FLIs.

Examples

use std::path::Path;

const speed_jiffies: u16 = 5;

flic::FlicFileWriter::create_fli(Path::new("ex.fli"), speed_jiffies);

Set the FLIC creator and creation time.

Set the most recent updater and update time.

Set the aspect ratio, i.e. x by y is a square.

Most often, the x:y aspect ratio will be 1:1. A 320x200 FLIC has a ratio of 6:5.

Close the FLIC file.

You must close the FLIC writer after you have supplied all the frames, including the ring frame, to write out the header.

The FLIC writer is not usable after being closed.

Encode the next frame in the FLIC.

You must supply the previous frame buffer, or None if it is the first frame. Upon reaching the last frame in the animation, you must also supply the first frame to create the ring frame.

Examples

use std::path::Path;

const SCREEN_W: u16 = 320;
const SCREEN_H: u16 = 200;
const NUM_COLS: usize = 256;
const speed_msec: u32 = 70;
let buf = [0; (SCREEN_W * SCREEN_H) as usize];
let pal = [0; 3 * NUM_COLS];

if let Ok(mut flic) = flic::FlicFileWriter::create(
        Path::new("ex.flc"), SCREEN_W, SCREEN_H, speed_msec) {
    let raster1 = flic::Raster::new(SCREEN_W as usize, SCREEN_H as usize, &buf, &pal);
    let raster2 = flic::Raster::new(SCREEN_W as usize, SCREEN_H as usize, &buf, &pal);
    // Write first frame.
    flic.write_next_frame(None, &raster1);
    // Write subsequent frames.
    flic.write_next_frame(Some(&raster1), &raster2);
    // Write ring frame.
    flic.write_next_frame(Some(&raster2), &raster1);
    flic.close();
}

Trait Implementations

impl Drop for FlicFileWriter
[src]

A method called when the value goes out of scope.