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: usizeCanvas width in pixels.
height: usizeCanvas 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
impl ImageBuffer
Sourcepub fn from_buffer(width: usize, height: usize, buf: Vec<u8>) -> Self
pub fn from_buffer(width: usize, height: usize, buf: Vec<u8>) -> Self
Creates an image buffer from an RGBA pixel buffer.
Sourcepub fn set_animation(&mut self, flag: bool)
pub fn set_animation(&mut self, flag: bool)
Enables or disables animation storage.
Sourcepub fn set_verbose(
&mut self,
verbose: fn(&str) -> Result<Option<CallbackResponse>, Box<dyn Error>>,
)
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
impl DrawCallback for ImageBuffer
Source§fn init(
&mut self,
width: usize,
height: usize,
option: Option<InitOptions>,
) -> Result<Option<CallbackResponse>, Box<dyn Error>>
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>>
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>>
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>>
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>>
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>>
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
impl PickCallback for ImageBuffer
Source§fn encode_start(
&mut self,
_: Option<EncoderOptions>,
) -> Result<Option<ImageProfiles>, Box<dyn Error>>
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>>
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>>
fn encode_end(&mut self, _: Option<EndOptions>) -> Result<(), Box<dyn Error>>
Finalizes encoding.