Struct WebPDecoder
pub struct WebPDecoder<R> { /* private fields */ }
WebP image format decoder.
Implementations
impl<R: BufRead + Seek> WebPDecoder<R>
fn new(r: R) -> Result<Self, DecodingError>Create a new
WebPDecoderfrom the readerr. The decoder performs many small reads, so the reader should be buffered.fn new_with_options(r: R, webp_decode_options: WebPDecodeOptions) -> Result<Self, DecodingError>Create a new
WebPDecoderfrom the readerrwith the optionsWebPDecodeOptions. The decoder performs many small reads, so the reader should be buffered.fn set_memory_limit(&mut self, limit: usize)Sets the maximum amount of memory that the decoder is allowed to allocate at once.
TODO: Some allocations currently ignore this limit.
fn background_color_hint(&self) -> Option<[u8; 4]>Get the background color specified in the image file if the image is extended and animated webp.
fn set_background_color(&mut self, color: [u8; 4]) -> Result<(), DecodingError>Sets the background color if the image is an extended and animated webp.
fn dimensions(&self) -> (u32, u32)Returns the (width, height) of the image in pixels.
fn has_alpha(&self) -> boolReturns whether the image has an alpha channel. If so, the pixel format is Rgba8 and otherwise Rgb8.
fn is_animated(&self) -> boolReturns true if the image is animated.
fn is_lossy(&mut self) -> boolReturns whether the image is lossy. For animated images, this is true if any frame is lossy.
fn num_frames(&self) -> u32Returns the number of frames of a single loop of the animation, or zero if the image is not animated.
fn loop_count(&self) -> LoopCountReturns the number of times the animation should loop.
fn loop_duration(&self) -> u64Returns the total duration of one loop through the animation in milliseconds, or zero if the image is not animated.
This is the sum of the durations of all individual frames of the image.
fn icc_profile(&mut self) -> Result<Option<Vec<u8>>, DecodingError>Returns the raw bytes of the ICC profile, or None if there is no ICC profile.
fn exif_metadata(&mut self) -> Result<Option<Vec<u8>>, DecodingError>Returns the raw bytes of the EXIF metadata, or None if there is no EXIF metadata.
fn xmp_metadata(&mut self) -> Result<Option<Vec<u8>>, DecodingError>Returns the raw bytes of the XMP metadata, or None if there is no XMP metadata.
fn output_buffer_size(&self) -> Option<usize>Returns the number of bytes required to store the image or a single frame, or None if that would take more than
usize::MAXbytes.fn read_image(&mut self, buf: &mut [u8]) -> Result<(), DecodingError>Returns the raw bytes of the image. For animated images, this is the first frame.
Fails with
ImageTooLargeifbufhas length different thanoutput_buffer_size()fn read_frame(&mut self, buf: &mut [u8]) -> Result<u32, DecodingError>Reads the next frame of the animation.
The frame contents are written into
bufand the method returns the duration of the frame in milliseconds. If there are no more frames, the method returnsDecodingError::NoMoreFramesandbufis left unchanged.Panics
Panics if the image is not animated.
fn reset_animation(&mut self)Resets the animation to the first frame.
Panics
Panics if the image is not animated.
fn set_lossy_upsampling(&mut self, upsampling_method: UpsamplingMethod)Sets the upsampling method that is used in lossy decoding
Auto Trait Implementations
impl<R> Freeze for WebPDecoder<R>
where
R: Freeze,
impl<R> RefUnwindSafe for WebPDecoder<R>
where
R: RefUnwindSafe,
impl<R> Send for WebPDecoder<R>
where
R: Send,
impl<R> Sync for WebPDecoder<R>
where
R: Sync,
impl<R> Unpin for WebPDecoder<R>
where
R: Unpin,
impl<R> UnsafeUnpin for WebPDecoder<R>
where
R: UnsafeUnpin,
impl<R> UnwindSafe for WebPDecoder<R>
where
R: UnwindSafe,
Blanket Implementations
impl<T> Any for WebPDecoder<R>
where
T: 'static + ?Sized,
fn type_id(&self) -> TypeId
impl<T> Borrow<T> for WebPDecoder<R>
where
T: ?Sized,
fn borrow(&self) -> &T
impl<T> BorrowMut<T> for WebPDecoder<R>
where
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
impl<T> From<T> for WebPDecoder<R>
fn from(t: T) -> TReturns the argument unchanged.
impl<T, U> Into<U> for WebPDecoder<R>
where
U: From<T>,
fn into(self) -> UCalls
U::from(self).That is, this conversion is whatever the implementation of
[From]<T> for Uchooses to do.
impl<T, U> TryFrom<U> for WebPDecoder<R>
where
U: Into<T>,
type Error = never;fn try_from(value: U) -> Result<T, never>
impl<T, U> TryInto<U> for WebPDecoder<R>
where
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error;fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>