本文介绍了加载位图或绘制图形?性能问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好吧,我将要画一个很大的屏幕上的昆虫的。我的问题是,如果我画一个蜘蛛,例如,会是更快的加载一个位图,矩阵,以正确的角度,并在屏幕上绘制(一遍又一遍),或使用canvas.drawLine画一只蚂蚁,画圆,等等?对于直接的比较:

Ok, I am going to be drawing a lot of "insects" on the screen. My question is, if I am drawing a spider for example, would it be faster to load a bitmap, matrix it to the correct angle, and draw it on screen (again and again), or draw an ant using the canvas.drawLine, drawCircle, etc? For a direct comparison:

位图:500字节瓦特/透明度

Bitmap: 500 bytes w/ transparency

得出:8 drawLines,2 drawCircles

Drawn: 8 drawLines, 2 drawCircles

我已经有很多事情,所以这里的表现是非常重要的。

I already have a lot going on, so performance here is very important.

在此先感谢!

推荐答案

这是要快得多绘制位图。真正重要的是多少像素您要画(即透支,这将影响最大的填充率。)使用位图还允许您创建更丰富的图形没有性能损失。

It is much faster to draw a bitmap. What really matters is how many pixels you are going to draw (i.e. the overdraw, which will impact the maximum fillrate.) Using bitmaps also allows you to create richer graphics without performance penalties.

这篇关于加载位图或绘制图形?性能问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-27 19:31