pub struct GifEncoder { /* private fields */ }Available on crate feature
gif only.Expand description
Builds an animated GIF from RGBA frames.
Buffer frames with Self::add_frame / Self::add_frame_owned, then
Self::finish, or stream with Self::encode_iter. For writing directly
to a file or socket, prefer GifWriter.
Implementations§
Source§impl GifEncoder
impl GifEncoder
Sourcepub fn new(width: u32, height: u32, plays: u32) -> Self
pub fn new(width: u32, height: u32, plays: u32) -> Self
New encoder; defaults enable dithering, dirty-rects, and local palettes.
Sourcepub fn options(self, opts: GifOptions) -> Self
pub fn options(self, opts: GifOptions) -> Self
Replace every option at once.
Sourcepub fn transparency(self, on: bool) -> Self
pub fn transparency(self, on: bool) -> Self
Sourcepub fn alpha_threshold(self, t: u8) -> Self
pub fn alpha_threshold(self, t: u8) -> Self
Sourcepub fn diff_rects(self, on: bool) -> Self
pub fn diff_rects(self, on: bool) -> Self
Sourcepub fn palette_mode(self, mode: PaletteMode) -> Self
pub fn palette_mode(self, mode: PaletteMode) -> Self
Sourcepub fn quantizer(self, q: QuantizerKind) -> Self
pub fn quantizer(self, q: QuantizerKind) -> Self
Sourcepub fn disposal(self, mode: DisposalMode) -> Self
pub fn disposal(self, mode: DisposalMode) -> Self
Sourcepub fn lzw_clear(self, mode: LzwClearMode) -> Self
pub fn lzw_clear(self, mode: LzwClearMode) -> Self
Sourcepub fn add_frame_owned(&mut self, rgba: Vec<u8>, delay_num: u16, delay_den: u16)
pub fn add_frame_owned(&mut self, rgba: Vec<u8>, delay_num: u16, delay_den: u16)
Add a frame by moving RGBA bytes (no extra clone of the pixel buffer).
Sourcepub fn add_frame(&mut self, rgba: &[u8], delay_num: u16, delay_den: u16)
pub fn add_frame(&mut self, rgba: &[u8], delay_num: u16, delay_den: u16)
Add a frame from a borrowed RGBA buffer (one copy into the encoder).
Sourcepub fn encode_iter<I>(self, frames: I) -> Vec<u8> ⓘ
pub fn encode_iter<I>(self, frames: I) -> Vec<u8> ⓘ
Encode an iterator of (rgba, delay_num, delay_den) frames.
With PaletteMode::Local this streams (keeps only the previous canvas).
With PaletteMode::Global / PaletteMode::Auto it may buffer frames
to build a shared palette.
Auto Trait Implementations§
impl Forget for GifEncoder
impl Freeze for GifEncoder
impl Move for GifEncoder
impl RefUnwindSafe for GifEncoder
impl Send for GifEncoder
impl Sync for GifEncoder
impl Unpin for GifEncoder
impl UnsafeUnpin for GifEncoder
impl UnwindSafe for GifEncoder
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more