是putImageData(...)比drawImage(...)更高性能吗? [英] Is putImageData(...) more performant than drawImage(...)?

查看:1197
本文介绍了是putImageData(...)比drawImage(...)更高性能吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想是这样,但我需要证明它。

I guess so, but I needed to prove it.

我想,这是相同的情况下,Flash和它的Bitmap vs BitmapData。基本上,BitmapData是Bitmap中数据的非可视提取,这允许非常容易和快速的操作。

I guess, it is the same case as with Flash and its Bitmap vs BitmapData. Basically, BitmapData is a non-visual extract of the data in the Bitmap, which allows for very easy and fast manipulations.

我认为对于高性能解决方案作为游戏,从每个图像(例如,每个精灵)提取ImageData,并将其缓存在资产字典是一个更好的解决方案,而不是一遍又一遍地在画布上绘制精灵本身。

I think that for high-performance solutions, such as games, extracting the ImageData from every image (for instance, every sprite), and caching it in an "assets" dictionary is a better solution than drawing the sprites themselves over the canvas over and over again.

有人可以证明这一点吗?

Could someone prove this?

推荐答案

可以清楚地看到使用 drawImage()使用画布和图像以及 putImageData()这里:

I take no credit for putting this test together, but you can clearly see the performance of using drawImage() with both a canvas and an image as well as the performance of putImageData() here:

http: //jsperf.com/canvas-drawimage-vs-putimagedata/3

现在, drawImage() putImageData()快得多。最后我听说,这不是为了和浏览器开发人员正在寻求提高性能差距。

As of right now, drawImage() is much faster than putImageData(). Last I heard, this was not intended and the browser developers were looking into improving the performance gap.

这篇关于是putImageData(...)比drawImage(...)更高性能吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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