Modify canvas from wasm

前端 未结 4 916
死守一世寂寞
死守一世寂寞 2021-02-10 05:53

Is it possible to efficiently modify the html5 canvas from web assembly?

Update:

var imageData = context.getImageData(x, y, w, h)
var buffer = imageData         


        
4条回答
  •  忘了有多久
    2021-02-10 05:58

    WebAssembly instances typically have a linear memory area which is exposed to the JavaScript API as an arraybuffer. This can either be allocated in JS and passed in when the WebAssembly instance is created, or the WebAssembly instance can create it and export it to the JS code. Either way the arraybuffer can be used to efficiently copy data into and out of a Canvas element (using createImageData, getImageData and putImageData).

提交回复
热议问题