A small BMP parser designed for embedded, no-std environments but usable anywhere. Beyond parsing the image header, no other allocations are made. A reference to the input image data is kept and slices are returned from it.
```rust use tinybmp::{Bmp, FileType, Header, Pixel};
let bmp = Bmp::fromslice(includebytes!("../tests/chessboard-8px-24bit.bmp")) .expect("Failed to parse BMP image");
// Read the BMP header asserteq!( bmp.header, Header { filetype: FileType::BM, filesize: 314, reserved1: 0, reserved2: 0, imagedatastart: 122, bpp: 24, imagewidth: 8, imageheight: 8, imagedata_len: 192 } );
// Check that raw image data slice is the correct length (according to parsed header) asserteq!(bmp.imagedata().len(), bmp.header.imagedatalen as usize);
// Get an iterator over the pixel coordinates and colors in this image and collect into a vec
let pixels: Vec
// Loaded example image is 8x8px assert_eq!(pixels.len(), 8 * 8); ```
Licensed under either of
at your option.
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.