Crate zune_ppm

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>{
    use zune_core::bytestream::ZCursor;
 let mut decoder = PPMDecoder::new(ZCursor::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(())
 }

Re-exports§

pub use zune_core;

Structs§

PPMDecoder
An instance of a PPM decoder
PPMEncoder
A PPM encoder

Enums§

PPMDecodeErrors
Decoding errors that may occur
PPMEncodeErrors
Errors occurring during encoding

Functions§

max_out_size
Gives expected minimum size for which the encoder wil guarantee that the given raw bytes will fit