zune_ppm/lib.rs
1/*
2 * Copyright (c) 2023.
3 *
4 * This software is free software;
5 *
6 * You can redistribute it or modify it under terms of the MIT, Apache License or Zlib license
7 */
8//! A Portable Pixmap and Portable FloatMap Format Decoder and Encoder
9//!
10//! This crate supports decoding and encoding of the following ppm formats
11//!
12//! # Specification
13//! [here](https://netpbm.sourceforge.net/doc/ppm.html)
14//!
15//!|Format | Decoder | Encoder |
16//!|-------|--------|--------|
17//!|P1-P3 | No | No |
18//!| P5 | Yes | Yes |
19//!| P6 | Yes | Yes |
20//!| P7 | Yes | Yes |
21//!| [PFM] | Yes | No |
22//!
23//!
24//![PFM]:https://www.pauldebevec.com/Research/HDR/PFM/
25//!
26//! # Example
27//! - Decoding PPM
28//!```no_run
29//! use zune_ppm::PPMDecoder;
30//! use zune_ppm::PPMDecodeErrors;
31//! use zune_core::result::DecodingResult;
32//!
33//! fn main()->Result<(),PPMDecodeErrors>{
34//! use zune_core::bytestream::ZCursor;
35//! let mut decoder = PPMDecoder::new(ZCursor::new(&[]));
36//! let pix = decoder.decode()?;
37//! match pix {
38//! DecodingResult::U8(_) => {
39//! // deal with 8 bit images
40//! }
41//! DecodingResult::U16(_) => {
42//! // deal with 16 bit images
43//! }
44//! DecodingResult::F32(_) => {
45//! // deal with 32 bit images (PFM)
46//! }
47//! _=>unreachable!()};
48//! Ok(())
49//! }
50//! ```
51#![forbid(unsafe_code)]
52#![no_std]
53extern crate alloc;
54
55pub use zune_core;
56
57pub use crate::decoder::*;
58pub use crate::encoder::*;
59
60mod decoder;
61mod encoder;