1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
//! PNG encoding and decoding.
//!
//! # Encoding
//!
//! Wrap pixels in an [`ImageRef`] (which validates the buffer size) and pass
//! it to [`encode`] or to a configured [`Encoder`]. The encoder writes grey
//! (1–16 bits), grey + alpha, RGB and RGBA (8 or 16 bits), choosing a scanline
//! filter per row adaptively, and can add a `pHYs` resolution and text
//! entries. Output is never interlaced.
//!
//! # Decoding
//!
//! [`decode`] (or [`Decoder`], to change the size limit) reads every
//! standard PNG: all colour types and bit depths, palettes, `tRNS`
//! transparency, Adam7 interlacing, any number of `IDAT` chunks. CRCs are
//! verified, unknown ancillary chunks skipped. The result is a
//! [`DecodedImage`], which keeps the file's native pixel layout and converts
//! to 8- or 16-bit RGBA on demand.
//!
//! ```
//! use pltrs_codec::png::{self, ColorType, ImageRef};
//!
//! let rgba = [10, 20, 30, 255, 40, 50, 60, 128];
//! let file = png::Encoder::new()
//! .text("Software", "pltrs")
//! .encode(ImageRef::rgba8(2, 1, &rgba)?)?;
//!
//! let image = png::decode(&file)?;
//! assert_eq!(image.color_type(), ColorType::Rgba);
//! assert_eq!(image.to_rgba8(), rgba);
//! assert_eq!(image.metadata().text[0].text, "pltrs");
//! # Ok::<(), Box<dyn std::error::Error>>(())
//! ```
pub use ;
pub use ;
pub use ;
pub use Decoder;
pub use Encoder;
pub use ;
pub use ;
pub use ImageRef;
pub use ;
pub use ;
/// Encodes `image` with the default [`Encoder`] settings.
/// Decodes a PNG file with the default [`Decoder`] limits.