在Safari上的createImageBitmap替代 [英] createImageBitmap alternative on Safari

查看:686
本文介绍了在Safari上的createImageBitmap替代的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想用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


  1. 构建了一个 ImageData 使用它的构造函数,基于asm.js代码使用的数组缓冲区的一部分,

  2. 调用 createImageBitmap ImageData 转换为 ImageBitmap

  3. 图像位图从工作人员传输到GUI线程和

  4. 使用 ImageBitmap 作为 CanvasRenderingContext2D.drawImage

  1. constructs an ImageData object using its constructor, based on a portion of the array buffer used by the asm.js code,
  2. calls createImageBitmap to turn the ImageData into an ImageBitmap,
  3. transfers that image bitmap from the worker to the GUI thread and
  4. uses that ImageBitmap as an argument to CanvasRenderingContext2D.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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆