Is it possible to transfer ImageBitmap directly from JS to WebAssembly without converting it to a typed array? Can ImageBitmap be some kind of "transferable" object between JS and WebAssembly as it is between the main thread and web worker?
The idea is to replace CanvasRenderingContext2D.getImageData() with something faster. Currently, I do this to apply filters on video:
- context.drawImage(imageBitmap, 0, 0);
- let imageData = context.getImageData();
- loop through imageData and apply chroma key filter.
I want to try to replace this with the next (if it's possible):
- transfer ImageBitmap to WebAssembly;
- convert ImageBitmap to ImageData;
- loop through ImageData and apply chrome key filter;
- transfer changed ImageData back to JS and draw it on canvas.
I'm unfamiliar with the possibilities of WebAssembly, so maybe sorry for the silly question.
Thanks.