Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

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

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages