| Crates.io | svpng |
| lib.rs | svpng |
| version | 0.1.1 |
| created_at | 2019-03-01 07:23:35.839292+00 |
| updated_at | 2019-03-01 07:54:42.300505+00 |
| description | A small function for saving RGB/RGBA image into uncompressed PNG |
| homepage | |
| repository | |
| max_upload_size | |
| id | 117928 |
| size | 472,211 |
Rust version of miloyip/svpng.
Either using the svpng crate or just copy the src/lib.rs somewhere you want.
use svpng::svpng;
use std::io;
fn main() -> io::Result<()> {
{
// RGB
let mut pix = Vec::new();
for y in 0..=255 {
for x in 0..=255 {
pix.push(x);
pix.push(y);
pix.push(128);
}
}
svpng("rgb.png", 256, 256, &pix, false)?;
}
{
// RGBA
let mut pix = Vec::new();
for y in 0..=255 {
for x in 0..=255 {
pix.push(x);
pix.push(y);
pix.push(128);
pix.push(x / 2 + y / 2);
}
}
svpng("rgba.png", 256, 256, &pix, true)?;
}
Ok(())
}
RGB

RGBA
