Skip to main content

Crate rasterrocket_encode

Crate rasterrocket_encode 

Source
Expand description

Image encoding — write a raster::Bitmap<P> to PPM, PGM, PBM, and PNG.

§Supported formats

FunctionFormatAccepted pixel types
write_ppmNetpbm P6 binaryRgb8, Bgr8, Rgba8 (Xbgr8), Cmyk8, DeviceN8
write_pgmNetpbm P5 binaryGray8
write_pbmNetpbm P4 binaryGray8 (0 = white, non-zero = black)
write_pngPNGRgb8, Gray8, Rgba8

All functions consume the output sink (W: Write). Wrap in std::io::BufWriter at the call site if buffering is needed.

§CMYK handling

Neither PPM nor PNG natively supports CMYK. write_ppm converts CMYK/DeviceN to RGB via the naïve subtractive ink-density formula R = 255 − C − K (PDF §10.3.3). For ICC-accurate colour, convert to Rgb8 before encoding.

Re-exports§

pub use pbm::write_pbm;
pub use pgm::write_pgm;
pub use png::write_png;
pub use ppm::write_ppm;

Modules§

pbm
Netpbm P4 (binary PBM) encoder.
pgm
Netpbm P5 (binary PGM) encoder.
png
PNG encoder (via the png crate).
ppm
Netpbm P6 (binary PPM) encoder.

Enums§

EncodeError
Errors that can occur during encoding.