Struct gif_dispose::Screen

source ·
pub struct Screen { /* private fields */ }
Expand description

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).

Implementations§

source§

impl Screen

source

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

Create an new Screen

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

source

pub fn new(width: usize, height: usize, global_pal: Option<&[RGB8]>) -> Self

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

Use rgb crate’s as_rgb() if you have palette as &[u8].

source

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

Advance the screen by one frame.

Use pixels_rgba() to get pixels afterwards

source

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

Low-level version of blit_frame

source

pub fn pixels_rgba(&mut self) -> ImgRef<'_, RGBA8>

Access the currently rendered pixels

source

pub fn pixels(&mut self) -> ImgRef<'_, RGBA8>

👎Deprecated: use pixels_rgba() instead. This method will return a different type in the next version

Use [pixels_rgba]

source

pub fn dispose_only(&mut self) -> TempDisposedStateScreen<'_>

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, None);
let mut tmp_screen = screen.dispose_only();
let incomplete_pixels = tmp_screen.pixels();
tmp_screen.then_blit(None, gif::DisposalMethod::Keep, 0, 0, buffer, None)?;
source

pub fn width(&self) -> usize

source

pub fn height(&self) -> usize

Auto Trait Implementations§

§

impl Freeze for Screen

§

impl RefUnwindSafe for Screen

§

impl Send for Screen

§

impl Sync for Screen

§

impl Unpin for Screen

§

impl UnwindSafe for Screen

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

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

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

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

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

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.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.