https://github.com/reshane/wbmp
wbmp encoder and decoder
https://github.com/reshane/wbmp
rust wbmp
Last synced: 5 months ago
JSON representation
wbmp encoder and decoder
- Host: GitHub
- URL: https://github.com/reshane/wbmp
- Owner: reshane
- License: apache-2.0
- Created: 2025-01-19T03:37:04.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-02-05T15:19:12.000Z (over 1 year ago)
- Last Synced: 2025-12-08T09:48:21.385Z (7 months ago)
- Topics: rust, wbmp
- Language: Rust
- Homepage:
- Size: 42 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE-APACHE
Awesome Lists containing this project
README
# WBMP encoding and decoding library
WBMP encoding and decoding library written in Rust.
## API
This library provides an `Encoder` and a `Decoder`.
### Encoding
```rust
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
```rust
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())?;
```