diff --git a/Cargo.toml b/Cargo.toml index bb3baa7..3267fda 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,6 +12,7 @@ edition = "2018" exclude = [ "tests/*", + "benches/*.gif", "gif-afl/*", ] diff --git a/Changes.md b/Changes.md new file mode 100644 index 0000000..a7c97db --- /dev/null +++ b/Changes.md @@ -0,0 +1,10 @@ +# v0.11 + +- Rename `Reader` to `Decoder`. +- Reworked `Decoder` into `DecodeOptions`. +- The decoding error is now opaque and no longer allocates a string. Adding + more information or more error conditions is forward compatible. +- Replace the lzw decoder with `weezl`, up to +350% throughput. +- The dysfunctional C-API has been (temporarily?) removed + - It may get reintroduced as a separate crate at some point +- Added a `std` feature. It must be active for now. diff --git a/README.md b/README.md index 9828871..86af3f7 100644 --- a/README.md +++ b/README.md @@ -10,20 +10,18 @@ This library provides all functions necessary to de- and encode GIF files. The high level interface consists of the two types [`Encoder`](https://docs.rs/gif/0.10.1/gif/struct.Encoder.html) and [`Decoder`](https://docs.rs/gif/0.10.1/gif/struct.Decoder.html). -They as builders for the actual en- and decoders and can be used to set various -options beforehand. ### Decoding GIF files ```rust // Open the file use std::fs::File; -use gif::SetParameter; -let mut decoder = gif::Decoder::new(File::open("tests/samples/sample_1.gif").unwrap()); +let input = File::open("tests/samples/sample_1.gif").unwrap(); // Configure the decoder such that it will expand the image to RGBA. -decoder.set(gif::ColorOutput::RGBA); +let mut options = gif::DecodeOptions::new(); +options.set_color_output(gif::ColorOutput::RGBA); // Read the file header -let mut decoder = decoder.read_info().unwrap(); +let mut decoder = options.read_info(input).unwrap(); while let Some(frame) = decoder.read_next_frame().unwrap() { // Process every frame } @@ -34,7 +32,7 @@ while let Some(frame) = decoder.read_next_frame().unwrap() { The encoder can be used to save simple computer generated images: ```rust -use gif::{Frame, Encoder, Repeat, SetParameter}; +use gif::{Frame, Encoder, Repeat}; use std::fs::File; use std::borrow::Cow; @@ -57,7 +55,7 @@ let beacon_states = [[ ]]; let mut image = File::create("target/beacon.gif").unwrap(); let mut encoder = Encoder::new(&mut image, width, height, color_map).unwrap(); -encoder.set(Repeat::Infinite).unwrap(); +encoder.set_repeat(Repeat::Infinite).unwrap(); for state in &beacon_states { let mut frame = Frame::default(); frame.width = width; diff --git a/src/lib.rs b/src/lib.rs index ee7e511..39e5b69 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -10,8 +10,6 @@ //! //! The high level interface consists of the two types //! [`Encoder`](struct.Encoder.html) and [`Decoder`](struct.Decoder.html). -//! They as builders for the actual en- and decoders and can be used to set various -//! options beforehand. //! //! ### Decoding GIF files //! @@ -142,3 +140,12 @@ fn round_trip() { } assert_eq!(&data[..], &data2[..]) } + +macro_rules! insert_as_doc { + { $content:expr } => { + #[doc = $content] extern { } + } +} + +// Provides the README.md as doc, to ensure the example works! +insert_as_doc!(include_str!("../README.md"));