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]
fn create(filename: &Path, w: u16, h: u16, speed_msec: u32) -> FlicResult<Self>
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);
fn create_fli(filename: &Path, speed_jiffies: u16) -> FlicResult<Self>
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);
fn set_creator(&mut self, creator: u32, created: u32)
Set the FLIC creator and creation time.
fn set_updater(&mut self, updater: u32, updated: u32)
Set the most recent updater and update time.
fn set_aspect_ratio(&mut self, x: u16, y: u16)
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.
fn close(self) -> FlicResult<()>
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.
fn write_next_frame(
&mut self,
prev: Option<&Raster>,
next: &Raster
) -> FlicResult<()>
&mut self,
prev: Option<&Raster>,
next: &Raster
) -> FlicResult<()>
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]
fn drop(&mut self)
A method called when the value goes out of scope.