| Crates.io | wbmp |
| lib.rs | wbmp |
| version | 0.1.2 |
| created_at | 2025-01-19 18:41:27.158427+00 |
| updated_at | 2025-02-05 15:20:17.596721+00 |
| description | WBMP encoder and decoder |
| homepage | https://github.com/reshane/wbmp |
| repository | https://github.com/reshane/wbmp |
| max_upload_size | |
| id | 1523087 |
| size | 27,172 |
WBMP encoding and decoding library written in Rust.
This library provides an Encoder and a Decoder.
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)?;
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())?;