1 unstable release

0.3.0 May 22, 2024

#908 in Parser implementations

Used in hydroper_razen


16K SLoC

Contains (Zip file, 93KB) tests/swfs/SoundStreamHead2.fla, (Cab file, 33KB) tests/swfs/DefineBitsJpeg2-MX.fla, (Cab file, 30KB) DefineButtonCxformSound-MX.fla, (Cab file, 19KB) tests/swfs/DefineFont-MX.fla, (Cab file, 28KB) tests/swfs/DefineMorphShape-MX.fla, (Zip file, 26KB) tests/swfs/PlaceObject3-Image.fla and 46 more.


crates.io docs.rs

A Rust library for reading and writing the Adobe Flash SWF file format.

# Cargo.toml
swf = "0.2"


use std::io::BufReader;
use std::fs::File;

let file = File::open("file.swf").unwrap();
let reader = BufReader::new(file);
let swf_buf = swf::decompress_swf(reader).unwrap();
let swf = swf::parse_swf(&swf_buf).unwrap();
println!("The SWF has {} frame(s).", swf.header.num_frames());
println!("The SWF has {} tag(s).", swf.tags.len());

Try cargo run --example reading in this repository to run this example.


use swf::*;
let header = Header {
    compression: Compression::Zlib,
    version: 6,
    stage_size: Rectangle {
        x_min: Twips::from_pixels(0.0), x_max: Twips::from_pixels(400.0),
        y_min: Twips::from_pixels(0.0), y_max: Twips::from_pixels(400.0)
    frame_rate: Fixed8::from_f32(60.0),
    num_frames: 1,
let tags = [
    Tag::SetBackgroundColor(Color { r: 255, g: 0, b: 0, a: 255 }),
let file = std::fs::File::create("file.swf").unwrap();
let writer = std::io::BufWriter::new(file);
swf::write_swf(&header, &tags, writer).unwrap();

Try cargo run --example writing in this repository to run this example.


Licensed under either of

at your option.


Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.


~182K SLoC