DEV Community

Discussion on: Using Rust and WebAssembly to Process Pixels from a Video Feed

Collapse
 
fallenstedt profile image
Alex Fallenstedt • Edited

Hey Jeff,

you have access to a 2D context of the canvas when the image is rendered onto a canvas element (assuming the browser is modern).

With the 2D context, you can invoke the method getImageData
developer.mozilla.org/en-US/docs/W...

This will return ImageData developer.mozilla.org/en-US/docs/W...

With the data property, you will have one-dimensional array containing the data in the RGBA order, with integer values between 0 and 255. You can process this data as you please, then create a new ImageData, and put this new data onto your buffer canvas with putImageData
developer.mozilla.org/en-US/docs/W...

Collapse
 
jeffhykin profile image
Jeff Hykin

Thanks! That's exactly what I needed.