A Flash Player emulator written in Rust
Go to file
Mike Welsh 44c9262089 Make various read methods public
Made various Reader methods public for use in Ruffle, and use
structs for Tag enum variants to make the API consistent.
2019-07-22 18:29:39 -07:00
src Make various read methods public 2019-07-22 18:29:39 -07:00
tests/swfs Update naming convention for test SWFs 2019-06-17 01:58:24 -07:00
.gitignore Add rustfmt.toml to .gitignore 2016-08-29 13:36:14 -07:00
.travis.yml Update Travis config; Fix some clippy lints 2017-07-03 21:50:47 -07:00
Cargo.toml Bump Cargo.toml to 0.1.1 2019-06-17 02:11:53 -07:00
LICENSE-APACHE Change license to MIT/Apache-2.0 2016-09-13 11:23:29 -07:00
LICENSE-MIT Change license to MIT/Apache-2.0 2016-09-13 11:23:29 -07:00
README.md Update naming convention for AVM2 SWFs 2019-06-17 02:04:48 -07:00

README.md

swf

crates.io docs.rs TravisCI

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

# Cargo.toml
[dependencies]
swf = "0.1"

Reading

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

let file = File::open("file.swf").unwrap();
let reader = BufReader::new(file);
let swf = swf::read_swf(reader).unwrap();
println!("The SWF has {} frames", swf.num_frames);

Writing

use swf::*;
let swf = Swf {
    header: Header {
        version: 6,
        compression: Compression::Zlib,
        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: 60.0,
        num_frames: 1,
    },
    tags: vec![
        Tag::SetBackgroundColor(Color { r: 255, g: 0, b: 0, a: 255 }),
        Tag::ShowFrame
    ]
};
let file = std::fs::File::create("file.swf").unwrap();
let writer = std::io::BufWriter::new(file);
swf::write_swf(&swf, writer).unwrap();

License

Licensed under either of

at your option.

Contribution

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.