2 unstable releases
0.2.0 | Apr 19, 2023 |
---|---|
0.1.0 | Mar 26, 2023 |
#17 in #n64
494 downloads per month
26KB
591 lines
farbe
Library for working with retro image formats
This library currently supports the following:
- converting to and from n64 formats
Installation
Add this to your Cargo.toml:
[dependencies]
farbe = "0.1.0"
How to use
As a cli
# convert to png (width and height are required in this case)
farbe test.rgba32 -o output.png -f rgba32 --width 24 --height 24
# convert to n64 format
farbe test.png -o output.rgba32 -f rgba32
As a library
use farbe::image::n64::{ImageFormat, NativeImage, PNGImage};
// convert to png
let bytes: &[u8] = include_bytes!("image.rgba32")
let image = NativeImage::read(bytes, ImageFormat::RGBA32, 160, 160).unwrap();
let mut output_file = std::fs::File::create("image.png").unwrap();
image.as_png(&mut output_file).unwrap();
// convert to n64 format
let bytes: &[u8] = include_bytes!("image.png");
let image = PNGImage::read(bytes).unwrap();
let mut output_file = std::fs::File::create("image.output.rgba32").unwrap();
image.as_rgba32(&mut output_file).unwrap();
Dependencies
~2.2–3MB
~56K SLoC