Skip to main content

decode

Function decode 

Source
pub fn decode(bytes: Arc<Vec<u8>>) -> DecodeFuture ⓘ
Expand description

Decode encoded image bytes (PNG/JPEG/…) with the platform’s own decoder.

ⓘ
day::task(async move {
    match day::decode_image(bytes).await {
        Ok(bitmap) => shown.set(Some(bitmap)),
        Err(e) => log::warn!("not an image: {e}"),
    }
});

Err(ImageError::Unsupported) where the backend has no byte decoder at all (Cap::ImageDecode); Err(ImageError::Decode) where it has one and the bytes are not an image it reads.

Day API ↩ Guides· daybrite.dev