https://github.com/chux0519/svpng
A small function for saving RGB/RGBA image into uncompressed PNG.
https://github.com/chux0519/svpng
Last synced: 8 months ago
JSON representation
A small function for saving RGB/RGBA image into uncompressed PNG.
- Host: GitHub
- URL: https://github.com/chux0519/svpng
- Owner: chux0519
- Created: 2019-03-01T07:37:50.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2019-03-01T07:38:02.000Z (over 7 years ago)
- Last Synced: 2024-12-29T08:23:48.677Z (over 1 year ago)
- Language: Rust
- Size: 276 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# svpng
Rust version of [miloyip/svpng](https://github.com/miloyip/svpng).
## Usage
Either using the `svpng` crate or just copy the `src/lib.rs` somewhere you want.
## Examples
```rust
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
