Simple .ppm loader written in Rust.
This is more of a toy project, I have written, to be able to easy reuse it for some of my experiments with 2d graphhics in Rust.
tinyppm
to your Cargo.toml
read_image_data
:```rust extern crate tinyppm;
fn myfunction(filename: &String) {
let (width, height, image) = tinyppm:ppmloader::readimagedata(filename);
// image
contains 32bit image data
}
```
tinyppm
supports only 'raw ppm' format (the most popular format of ppm. More details: ppm format specification ).
Another restriction that is important is that at them moment tinyppm
supports reading only truecolor (24bpp - 3 color channels, 8b per channel) images. After the image is read it is converted to RGB+A format (32bpp) so that it is ready to be pushed directly to framebuffer.
If you want to check how it works, please have a look at ppm_viewer
which is simple image viewer written in Rust: https://github.com/MaciekTalaska/2deffects/tree/master/ppmviewer
This code is released under the MIT license.