在Safari上的createImageBitmap替代 [英] createImageBitmap alternative on Safari
问题描述
我想用web worker上运行的一些asm.js代码生成图像。我想定期将这种计算的最新状态与其他一些内容一起合成到用户可见的二维画布上。目前我的代码是
I'd like to generate images in a bit of asm.js code running on a web worker. And I'd like to regularly composite the latest state of that computation onto a user-visible 2d canvas, together with some other content. Currently I have code which
- 构建了一个
ImageData
使用它的构造函数,基于asm.js代码使用的数组缓冲区的一部分, - 调用
createImageBitmap
将ImageData
转换为ImageBitmap
, - 将图像位图从工作人员传输到GUI线程和
- 使用
ImageBitmap
作为CanvasRenderingContext2D.drawImage
。
- constructs an
ImageData
object using its constructor, based on a portion of the array buffer used by the asm.js code, - calls
createImageBitmap
to turn theImageData
into anImageBitmap
, - transfers that image bitmap from the worker to the GUI thread and
- uses that
ImageBitmap
as an argument toCanvasRenderingContext2D.drawImage
.
事情在最近的Chrome和Firefox中运行良好,但Safari 9.1.3显然没有 createImageBitmap
函数。 我如何以一种适用于Safari的方式进行上述操作?
Things work nicely in recent Chrome and Firefox, but Safari 9.1.3 apparently has no createImageBitmap
function. How would I do something like the above in a way that works on Safari?
是否有一些图像的低成本编码,为它创建一个 data:image / png ...
?有没有其他方法可以将一个字节数组转换为可以馈送给 drawImage
?
Is there some low-cost encoding of images, short of creating a data:image/png…
for it? Is there some other way to turn a byte array into something you can feed to drawImage
?
这篇关于在Safari上的createImageBitmap替代的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!