Skip to main content

Module container

Module container 

Source
Expand description

PNG / WebP / AVIF container helpers for heightmap RGB bytes.

Each container is gated on its own cargo feature so callers only pay the compile-time cost of what they actually use:

FeatureProvidesBackend
pngrgb_to_pngimage/png
webprgb_to_webpimage/webp (lossless)
avifrgb_to_avifimage/avif (ravif, encode-only)

decode_image auto-detects whichever formats are compiled in. WebP encoding is lossless — lossy WebP would need libwebp which is out of scope here.

For runtime-chosen container format use the ContainerFormat enum and the dispatching rgb_to_container; calling with a format whose feature wasn’t enabled returns ContainerError::Unsupported rather than failing to compile.

Structs§

DecodedImage
A decoded image returned by decode_image.
ParseContainerFormatError
Error returned by ContainerFormat::from_str for an unrecognised name.

Enums§

ContainerError
Error returned by rgb_to_container.
ContainerFormat
Identifies one of the supported image container formats for the runtime-dispatched rgb_to_container entry point.

Functions§

decode_image
Decode container bytes to raw RGB. The format is auto-detected from the bytes’ header.
rgb_to_avif
Wrap raw width × height × 3 RGB bytes in an AVIF container Vec<u8>.
rgb_to_avif_to_writer
Encode raw width × height × 3 RGB bytes as AVIF directly to a writer.
rgb_to_container
Wrap raw width × height × 3 RGB bytes in the chosen container format.
rgb_to_container_to_writer
Stream-encode raw width × height × 3 RGB bytes into the chosen container format, writing directly to writer without an intermediate Vec<u8>. Pair with crate::heightmap::encode_to for an allocation-free DEM → image pipeline.
rgb_to_png
Wrap raw width × height × 3 RGB bytes in a PNG container Vec<u8>.
rgb_to_png_to_writer
Encode raw width × height × 3 RGB bytes as PNG directly to a writer.
rgb_to_webp
Wrap raw width × height × 3 RGB bytes in a lossless WebP container Vec<u8>.
rgb_to_webp_to_writer
Encode raw width × height × 3 RGB bytes as lossless WebP directly to a writer.

Type Aliases§

ImageError
Re-export of image::ImageError for callers that don’t want to pull in the image crate directly.