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 74
//! # libwebp //! //! This is a binding to [the libwebp library](https://developers.google.com/speed/webp/download). //! //! ## Usage //! //! ### Preparation //! //! ```toml //! # Cargo.toml //! //! [dependencies] //! libwebp = { version = "0.1.2", features = ["0_6"] } //! ``` //! //! ### Simple decoding //! //! You can use [`WebPDecodeRGBA`] or [`WebPDecodeRGBAInto`] families for //! simple decoding. //! //! [`WebPDecodeRGBA`]: fn.WebPDecodeRGBA.html //! [`WebPDecodeRGBAInto`]: fn.WebPDecodeRGBAInto.html //! //! ```rust //! use libwebp::WebPDecodeRGBA; //! //! let data: &[u8]; //! # let data: &[u8] = include_bytes!("lena.webp"); //! //! let (width, height, buf) = WebPDecodeRGBA(data).unwrap(); //! # assert_eq!((width, height), (128, 128)); //! assert_eq!(buf.len(), width as usize * height as usize * 4); //! eprintln!("width = {}, height = {}", width, height); //! eprintln!( //! "top-left pixel: rgba({}, {}, {}, {})", //! buf[0], //! buf[1], //! buf[2], //! buf[3] as f64 / 255.0, //! ) //! ``` //! //! ### Simple encoding //! //! You can use [`WebPEncodeRGBA`] or [`WebPEncodeLosslessRGBA`] families for //! simple encoding. //! //! [`WebPEncodeRGBA`]: fn.WebPEncodeRGBA.html //! [`WebPEncodeLosslessRGBA`]: fn.WebPEncodeLosslessRGBA.html //! //! ```rust //! use libwebp::{WebPEncodeRGBA, WebPEncodeLosslessRGBA}; //! //! let buf: &[u8] = &[ //! 255, 255, 255, 255, // white //! 255, 0, 0, 255, // red //! 0, 255, 0, 255, // green //! 0, 0, 255, 255, // blue //! ]; //! let data = WebPEncodeRGBA(buf, 2, 2, 8, 75.0).unwrap(); //! let lossless_data = WebPEncodeLosslessRGBA(buf, 2, 2, 8).unwrap(); //! assert_eq!(&data[..4], b"RIFF"); //! assert_eq!(&data[8..12], b"WEBP"); //! assert_eq!(&lossless_data[..4], b"RIFF"); //! assert_eq!(&lossless_data[8..12], b"WEBP"); //! ``` pub use crate::decode::*; pub use crate::encode::*; pub mod boxed; mod decode; mod encode; pub mod error;