Crate zune_ppm

source ·
Expand description

A Portable Pixmap and Portable FloatMap Format Decoder and Encoder

This crate supports decoding and encoding of the following ppm formats

Specification

here

FormatDecoderEncoder
P1-P3NoNo
P5YesYes
P6YesYes
P7YesYes
PFMYesNo

Example

  • Decoding PPM
 use zune_ppm::PPMDecoder;
 use zune_ppm::PPMDecodeErrors;
 use zune_core::result::DecodingResult;

 fn main()->Result<(),PPMDecodeErrors>{
    let mut decoder = PPMDecoder::new(&[]);
    let pix = decoder.decode()?;
    match pix {  
        DecodingResult::U8(_) => {
            // deal with 8 bit images
        }
        DecodingResult::U16(_) => {
            // deal with 16 bit images
        }
        DecodingResult::F32(_) => {
            // deal with 32 bit images (PFM)
        },
        _=>unreachable!()};
 Ok(())
 }

Structs

Enums

Functions

  • Gives expected minimum size for which the encoder wil guarrantee that the given raw bytes will fit