pub struct GifDecoder;Expand description
GIF decoder.
Implementations§
Source§impl GifDecoder
impl GifDecoder
Sourcepub fn decode_animated(&self, data: &[u8]) -> CodecResult<AnimatedImage>
pub fn decode_animated(&self, data: &[u8]) -> CodecResult<AnimatedImage>
Decode an animated GIF into all of its frames.
The single-frame ImageDecoder::decode path returns only the
first frame — convenient for static GIFs but loses every
subsequent frame of an animation. decode_animated walks the
full frame stream, preserving per-frame delay, disposal, and
offset.
Each frame’s image is its own Image sized to the frame’s
local width/height (not the canvas). The x_offset / y_offset
fields on crate::AnimationFrame place the frame inside the
animation canvas; callers performing playback composite those
frames onto the canvas according to the frame’s
crate::DisposalMethod and crate::BlendMethod.
GIF delays arrive in 10ms ticks (Frame::delay), which this
converts to std::time::Duration. A zero delay is preserved
as Duration::ZERO — downstream renderers typically clamp these
to a minimum of 20ms to avoid CPU-pegging animations, but that
policy belongs to the renderer, not the codec.
§Errors
Returns CodecError if data is not a valid GIF, contains no
frames, or a frame image cannot be built.
Trait Implementations§
Source§impl Debug for GifDecoder
impl Debug for GifDecoder
Source§impl Default for GifDecoder
impl Default for GifDecoder
Source§impl ImageDecoder for GifDecoder
impl ImageDecoder for GifDecoder
Source§fn decode<R: Read>(&self, reader: R) -> CodecResult<Image>
fn decode<R: Read>(&self, reader: R) -> CodecResult<Image>
Source§fn format(&self) -> ImageFormat
fn format(&self) -> ImageFormat
Source§fn decode_bytes(&self, data: &[u8]) -> CodecResult<Image>
fn decode_bytes(&self, data: &[u8]) -> CodecResult<Image>
Source§fn can_decode(&self, data: &[u8]) -> bool
fn can_decode(&self, data: &[u8]) -> bool
Auto Trait Implementations§
impl Freeze for GifDecoder
impl RefUnwindSafe for GifDecoder
impl Send for GifDecoder
impl Sync for GifDecoder
impl Unpin for GifDecoder
impl UnsafeUnpin for GifDecoder
impl UnwindSafe for GifDecoder
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
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> ⓘ
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> ⓘ
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