img_qoi/lib.rs
1//! [QOI](https://github.com/phoboslab/qoi) (Quite OK Image) manipulation library.
2//!
3//! # Examples
4//!
5//! Convert QOI to PNG (with [`image`] crate):
6//!
7//! ```no_run
8//! use image::RgbaImage;
9//! use img_qoi::*;
10//!
11//! # fn main() -> anyhow::Result<()> {
12//! let (desc, buf_rgba) = qoi_open("foo.qoi", QoiChannels::Rgba)?;
13//!
14//! let img = RgbaImage::from_vec(desc.width().get(), desc.height().get(), buf_rgba).unwrap();
15//! img.save("foo.png")?;
16//! # Ok(())
17//! # }
18//! ```
19//!
20//! Convert PNG to QOI (with [`image`] crate):
21//!
22//! ```no_run
23//! use std::num::NonZeroU32;
24//! use img_qoi::*;
25//!
26//! # fn main() -> anyhow::Result<()> {
27//! let img = image::open("foo.png")?;
28//! let img = img.to_rgba8();
29//!
30//! let desc = QoiDesc::new(
31//! NonZeroU32::new(img.width()).unwrap(),
32//! NonZeroU32::new(img.height()).unwrap()
33//! );
34//!
35//! // `RgbaImage` implements `Deref<[u8]>`.
36//! qoi_save_from_buffer("foo.qoi", &desc, &*img, QoiChannels::Rgba)?;
37//! # Ok(())
38//! # }
39//! ```
40//!
41//! [`image`]: https://docs.rs/image/
42
43mod decode;
44mod encode;
45mod error;
46mod input;
47mod output;
48mod pixel;
49mod qoi;
50
51pub use self::decode::*;
52pub use self::encode::*;
53pub use self::error::*;
54pub use self::input::*;
55pub use self::output::*;
56pub use self::pixel::*;
57pub use self::qoi::*;