Skip to main content

ImageBuffer

Struct ImageBuffer 

Source
pub struct ImageBuffer {
    pub width: usize,
    pub height: usize,
    pub background_color: Option<RGBA>,
    pub buffer: Option<Vec<u8>>,
    pub animation: Option<Vec<AnimationLayer>>,
    pub current: Option<usize>,
    pub loop_count: Option<u32>,
    pub first_wait_time: Option<u64>,
    pub metadata: Option<HashMap<String, DataMap>>,
    /* private fields */
}
Expand description

Default in-memory RGBA image store used by decoders and encoders.

Fields§

§width: usize

Canvas width in pixels.

§height: usize

Canvas height in pixels.

§background_color: Option<RGBA>

Optional background color.

§buffer: Option<Vec<u8>>

Base canvas RGBA pixels.

§animation: Option<Vec<AnimationLayer>>

Animation frames, if present.

§current: Option<usize>

Current animation frame index while decoding.

§loop_count: Option<u32>

Animation loop count, if known.

§first_wait_time: Option<u64>

Delay of the first frame, if known.

§metadata: Option<HashMap<String, DataMap>>

Arbitrary metadata collected during decode.

Implementations§

Source§

impl ImageBuffer

Source

pub fn new() -> Self

Creates an empty image buffer.

Source

pub fn from_buffer(width: usize, height: usize, buf: Vec<u8>) -> Self

Creates an image buffer from an RGBA pixel buffer.

Source

pub fn set_animation(&mut self, flag: bool)

Enables or disables animation storage.

Source

pub fn set_verbose( &mut self, verbose: fn(&str) -> Result<Option<CallbackResponse>, Box<dyn Error>>, )

Installs a verbose logging callback used by decoders.

Trait Implementations§

Source§

impl DrawCallback for ImageBuffer

Source§

fn init( &mut self, width: usize, height: usize, option: Option<InitOptions>, ) -> Result<Option<CallbackResponse>, Box<dyn Error>>

Initializes the in-memory canvas.

Source§

fn draw( &mut self, start_x: usize, start_y: usize, width: usize, height: usize, data: &[u8], _: Option<DrawOptions>, ) -> Result<Option<CallbackResponse>, Box<dyn Error>>

Draws part of the current image or animation frame.

Source§

fn terminate( &mut self, _: Option<TerminateOptions>, ) -> Result<Option<CallbackResponse>, Box<dyn Error>>

Finalizes decoding.

Source§

fn next( &mut self, opt: Option<NextOptions>, ) -> Result<Option<CallbackResponse>, Box<dyn Error>>

Starts a new animation frame in the buffer.

Source§

fn verbose( &mut self, str: &str, _: Option<VerboseOptions>, ) -> Result<Option<CallbackResponse>, Box<dyn Error>>

Passes through verbose decoder output.

Source§

fn set_metadata( &mut self, key: &str, value: DataMap, ) -> Result<Option<CallbackResponse>, Box<dyn Error>>

Stores decoded metadata on the buffer.

Source§

impl PickCallback for ImageBuffer

Source§

fn encode_start( &mut self, _: Option<EncoderOptions>, ) -> Result<Option<ImageProfiles>, Box<dyn Error>>

Exposes the image profile to encoders.

Source§

fn encode_pick( &mut self, start_x: usize, start_y: usize, width: usize, height: usize, _: Option<PickOptions>, ) -> Result<Option<Vec<u8>>, Box<dyn Error>>

Reads an RGBA rectangle from the base canvas.

Source§

fn encode_end(&mut self, _: Option<EndOptions>) -> Result<(), Box<dyn Error>>

Finalizes encoding.

Source§

fn metadata( &mut self, ) -> Result<Option<HashMap<String, DataMap>>, Box<dyn Error>>

Returns stored metadata.

Auto Trait Implementations§

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>,

Source§

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>,

Source§

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.