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
impl Screen
sourcepub fn new_decoder<T: Read>(reader: &Decoder<T>) -> Self
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);
sourcepub fn new(width: usize, height: usize, global_pal: Option<&[RGB8]>) -> Self
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]
.
sourcepub fn blit_frame(&mut self, frame: &Frame<'_>) -> Result<(), Error>
pub fn blit_frame(&mut self, frame: &Frame<'_>) -> Result<(), Error>
Advance the screen by one frame.
Use pixels_rgba()
to get pixels afterwards
sourcepub fn blit(
&mut self,
local_pal: Option<&[RGB8]>,
method: DisposalMethod,
left: u16,
top: u16,
buffer: ImgRef<'_, u8>,
transparent: Option<u8>
) -> Result<(), Error>
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
sourcepub fn pixels_rgba(&mut self) -> ImgRef<'_, RGBA8>
pub fn pixels_rgba(&mut self) -> ImgRef<'_, RGBA8>
Access the currently rendered pixels
sourcepub fn pixels(&mut self) -> ImgRef<'_, RGBA8>
👎Deprecated: use pixels_rgba() instead. This method will return a different type in the next version
pub fn pixels(&mut self) -> ImgRef<'_, RGBA8>
Use [pixels_rgba
]
sourcepub fn dispose_only(&mut self) -> TempDisposedStateScreen<'_>
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)?;