Skip to main content

Crate valo_codec

Crate valo_codec 

Source
Expand description

Image decoding for Valo: encoded bytes in, drawable Images out.

The engine itself never decodes (hosts upload images); this crate is the optional piece a host adds when it wants Valo to do that job. It has no codecs of its own. A host registers Decoders — the platform’s native one first where it exists, a portable software one as fallback — and an ImageLoader tries them in that order for each image.

Decoders produce pixels or a texture; the loader alone turns those into images through ImageContext. That split is what lets a native codec deliver a texture it already decoded into GPU-shared memory, with no readback, while software decoders never touch the GPU.

Results arrive as Pending values, which are futures. With ImageLoader::new the work runs inside the first poll, on the polling thread — the shape for a single-threaded host or the web. With ImageLoader::with_worker (the worker feature) a dedicated thread decodes and uploads, and the poll wakes when the image is ready.

use valo_codec::{DecodeOptions, ImageLoader};

let loader = ImageLoader::new(context.image_context(), decoders);
let options = DecodeOptions { max_size: Some([512, 512]), mipmaps: true, ..Default::default() };
let image = loader.decode(bytes, options).await?;

Structs§

Codec
Codec is an opened image whose frames are decoded one at a time, on request.
Declined
Declined records one decoder passing on an image.
DecodeLimits
DecodeLimits bounds what a decode may consume, so hostile bytes cannot exhaust memory.
DecodeOptions
DecodeOptions says how large a decode may be and what the caller wants out of it.
DecodedFrame
DecodedFrame is one complete frame as a decoder produced it, before it becomes an image.
Frame
Frame is one decoded frame, ready to draw.
ImageInfo
ImageInfo is what is known about an image once it is open, before any frame is decoded.
ImageLoader
ImageLoader decodes encoded images into drawable Images with registered decoders.
OpenRequest
OpenRequest is everything a decoder needs to open one image.
Pending
Pending is a decode result on its way.

Enums§

DecodeError
DecodeError is why a decode did not produce an image.
FramePixels
FramePixels is what a decoder hands back — never an image; the loader makes those.
OpenError
OpenError is why a decoder did not open an image.
Repetition
Repetition is how an animation continues once it has played through.

Traits§

Decoder
Decoder is one codec library, such as Apple’s ImageIO or the portable image crate.
FrameReader
FrameReader is one opened image, yielding complete composited frames in order.

Functions§

fit_within
fit_within scales source down to fit bounds, keeping its aspect ratio and never returning a zero side. A source that already fits is returned unchanged.

Type Aliases§

Decoding
Decoding is an answer a decoder is still working on.