Skip to content

reshane/wbmp

Repository files navigation

WBMP encoding and decoding library

WBMP encoding and decoding library written in Rust.

API

This library provides an Encoder and a Decoder.

Encoding

use std::fs::File;
use wbmp::Encoder;

let img_data = vec![
    0xFF, 0x00, 0xFF, 0x00,
    0xFF, 0x00, 0xFF, 0x00,
    0xFF, 0x00, 0xFF, 0x00,
    0xFF, 0x00, 0xFF, 0x00,
];
let (width, height) = (4, 4);
let mut out_file = File::create("checker.wbmp")?;
let mut encoder = Encoder::new(&mut out_file);
encoder.encode(&img_data, width, height, wbmp::ColorType::Luma8)?;

Decoding

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

let f = BufReader::new(File::open("path/to/file.wbmp").unwrap());
let mut decoder = Decoder::new(f)?;
let (width, height) = decoder.dimensions();

let mut img_data = vec![0_u8; (width * height) as usize];
decoder.read_image_data(img_data.as_mut_slice())?;

About

wbmp encoder and decoder

Topics

Resources

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages