frus-image
PNG and JPEG decoding into frus's ImageData.
Layer: Foundations. A deliberately narrow crate: frus-core holds raw pixels and no
decoder, and this one adds image, with only the PNG
and JPEG formats turned on, so nothing else inherits its dependency tree. See
ARCHITECTURE.md.
What you reach for
decode: bytes in, sRGB RGBAImageDataout, the format detected from the bytes.dimensions: an image's size, read from its header without decoding it.decode_at: the same at aDecodeSize, the size the picture is shown at. A JPEG is decoded scaled straight from the file; other formats are downsampled once.DecodeError: an unrecognised format or corrupt data.
Example
// Encode a 2x2 red image as PNG, then decode it back.
let red = from_pixel;
let mut png = Vecnew;
ImageRgba8
.write_to
.unwrap;
let decoded = decode.unwrap;
assert_eq!;
Part of frus
Applications use it through frus-widgets' images feature (Image::memory, asset!),
on by default. See the workspace README.
Licensed under MIT or Apache-2.0.