[][src]Struct gif_dispose::Screen

pub struct Screen<PixelType = RGBA8> {
    pub pixels: ImgVec<PixelType>,
    // some fields omitted

Combined GIF frames forming a "virtual screen". See Screen::new_decoder.

Pixel type can be RGB8 or RGBA8. The size is overall GIF size (grater or equal individual frame sizes).


pixels: ImgVec<PixelType>

Result of combining all frames so far. It's in RGB/RGBA.


impl Screen<RGBA8>[src]

pub fn new_decoder<T: Read>(reader: &Decoder<T>) -> Self[src]

Create an new Screen with RGBA pixel type (the best choice for GIF)

Make sure Reader is set to use Indexed color. options.set_color_output(gif::ColorOutput::Indexed);

impl<PixelType: From<RGB8> + Copy + Default> Screen<PixelType>[src]

#[must_use]pub fn from_decoder<T: Read>(reader: &Decoder<T>) -> Self[src]

Create an new Screen with either RGB8 or RGBA8 pixel type. Allows ignoring transparency.

You may need type hints or use the screen.pixels to tell Rust whether you want RGB8 or RGBA8.

#[must_use]pub fn new(
    width: usize,
    height: usize,
    _bg_color: PixelType,
    global_pal: Option<Vec<PixelType>>
) -> Self

Manual setup of the canvas. You probably should use from_reader instead.

bg_color argument will be ignored. It appears that nobody tries to follow the GIF spec, and background must always be transparent.

pub fn blit_frame(
    &mut self,
    frame: &Frame<'_>
) -> Result<ImgRef<'_, PixelType>, Error>

Advance the screen by one frame.

The result will be in screen.pixels.buf

pub fn blit(
    &mut self,
    local_pal: Option<&[PixelType]>,
    method: DisposalMethod,
    left: u16,
    top: u16,
    buffer: ImgRef<'_, u8>,
    transparent: Option<u8>
) -> Result<ImgRef<'_, PixelType>, Error>

Low-level version of blit_frame

pub fn dispose(&mut self) -> TempDisposedStateScreen<'_, PixelType>[src]

Advanced usage. You do not need to call this. It exposes an incompletely-drawn screen.

Call to this method must always be followed by .then_blit() to fix the incomplete state.

The state is after previous frame has been disposed, but before the next frame has been drawn. This state is never visible on screen.

This method is for GIF encoders to help find minimal difference between frames, especially when transparency is involved ("background" disposal method).

use gif_dispose::*;
let mut screen = Screen::new(320, 200, RGBA8::new(0,0,0,0), None);
let mut tmp_screen = screen.dispose();
let incomplete_pixels = tmp_screen.pixels();
tmp_screen.then_blit(None, gif::DisposalMethod::Keep, 0, 0, buffer, None)?;

Auto Trait Implementations

impl<PixelType> RefUnwindSafe for Screen<PixelType> where
    PixelType: RefUnwindSafe

impl<PixelType> Send for Screen<PixelType> where
    PixelType: Send

impl<PixelType> Sync for Screen<PixelType> where
    PixelType: Sync

impl<PixelType> Unpin for Screen<PixelType> where
    PixelType: Unpin

impl<PixelType> UnwindSafe for Screen<PixelType> where
    PixelType: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized

impl<T> Borrow<T> for T where
    T: ?Sized

impl<T> BorrowMut<T> for T where
    T: ?Sized

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.