Skip to content

Instantly share code, notes, and snippets.

@gonzaloruizdevilla
Created September 5, 2019 15:46
Show Gist options
  • Save gonzaloruizdevilla/edc6e93d63e66f40f970ea2ced4dbbf0 to your computer and use it in GitHub Desktop.
Save gonzaloruizdevilla/edc6e93d63e66f40f970ea2ced4dbbf0 to your computer and use it in GitHub Desktop.
//retrieve image pixels (4 bytes per pixel: RBGA)
const data = imageData.data;
//copy to bytes to shared memory
mem.set(data);
//invoque 'fn' Wasm filter. We need to inform of the image byte size
const byteSize = data.length;
instance.exports[fn](byteSize, ...args);
//copy the response from the shared memory into the canvas imageData
data.set(mem.slice(byteSize, 2*byteSize))
//update canvas
ctx.putImageData(imageData, 0, 0);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment