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
//! Implements GIF disposal method for the gif crate.
//!
//! The gif crate only exposes raw frame data that is not sufficient
//! to render GIFs properly. GIF requires special composing of frames
//! which, as this crate shows, is non-trivial.
//!
//! ```rust,no_run
//! let file = std::fs::File::open("example.gif")?;
//!
//! let mut gif_opts = gif::DecodeOptions::new();
//! // Important:
//! gif_opts.set_color_output(gif::ColorOutput::Indexed);
//!
//! let mut decoder = gif_opts.read_info(file)?;
//! let mut screen = gif_dispose::Screen::new_decoder(&decoder);
//!
//! while let Some(frame) = decoder.read_next_frame()? {
//!     screen.blit_frame(&frame)?;
//!     screen.pixels.clone(); // that's the frame now in RGBA format
//! }
//! # Ok::<_, Box<dyn std::error::Error>>(())
//! ```

mod disposal;
mod screen;

pub use crate::screen::Screen;
pub use rgb::{RGB8, RGBA8};

use std::error::Error as StdError;
use std::fmt;

#[derive(Eq, PartialEq, Copy, Clone, Debug)]
pub enum Error {
    NoPalette,
}

impl fmt::Display for Error {
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
        f.write_str("No palette")
    }
}

impl StdError for Error {}