svpng 0.1.1

A small function for saving RGB/RGBA image into uncompressed PNG
Documentation
  • Coverage
  • 25%
    1 out of 4 items documented1 out of 2 items with examples
  • Size
  • Source code size: 471.83 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 1.28 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Links
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • chux0519

svpng

Rust version of miloyip/svpng.

Usage

Either using the svpng crate or just copy the src/lib.rs somewhere you want.

Examples

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

rgb


RGBA

rgba