Use Web Worker to getImageData from a file

时光毁灭记忆、已成空白 提交于 2019-12-11 11:51:54

问题


Is it possible to decode the image data from a file in a Web Worker so that I can pass it to the main thread and use putImageData. This is presumably faster than just calling drawImage.


回答1:


Yes it is. The WebWorker API specification allows you to simply postMessage ImageData and ArrayViews to and from it. However, not all implementations currently have this enabled afaik. You may want to have a look at this video from JSConf'11 that also touches this topic.

That beeing said, putImageData is much slower than drawImage, at least when I tested them earlier this year. See this stackoverflow answer for details, especially this jsPerf testcase comparing putImageData, getImageData, toDataURL and drawImage.



来源:https://stackoverflow.com/questions/7072295/use-web-worker-to-getimagedata-from-a-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!