INNER CODE UNIT · Rust

new_from_byteslice

silvia-odwyer/photon · crate/src/lib.rs:104

    pub fn new_from_byteslice(vec: Vec<u8>) -> PhotonImage {
        let slice = vec.as_slice();

        let img = image::load_from_memory(slice).unwrap();

        let width = img.width();
        let height = img.height();

        // Consume the decode instead of cloning it; transient full-frame
        // copies permanently grow wasm linear memory.
        let raw_pixels = img.into_rgba8().into_raw();

        PhotonImage {
            raw_pixels,
            width,
            height,
        }
    }

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…