Skip to main content

image_encode_formats

Function image_encode_formats 

Source
pub fn image_encode_formats() -> Vec<ImageFormat>
Expand description

Raster images from bytes (docs/images.md): decode an encoded PNG or JPEG the app already holds (a download, a file the user picked, a paste) into the platform’s image type, then show it with image(&bitmap) or draw it with Draw::image.

Bitmap is a handle, not the pixels: they live in the toolkit and are released when the last handle drops. Decoding is asynchronous because several backends decode off the main thread. Probe image_decode_support() / image_encode_support() before offering an affordance that depends on either, and image_encode_formats() before offering a format, since every platform here reads more formats than it writes. Which formats Bitmap::encode can write here: the Cap::ImageEncode counterpart of font_families(). Empty where encoding is unsupported.