INNER CODE UNIT · Rust

new_from_base64

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

    pub fn new_from_base64(base64: &str) -> PhotonImage {
        base64_to_image(base64)
    }

    /// Create a new PhotonImage from a byteslice.
    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 {

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…