问题描述
我目前正在绘制位图
到 SurfaceView
使用 Canvas.drawBitmap()
。这似乎真的减少我的帧率,我想知道我能做些什么来解决这个问题。我参考,我在的onDraw()
方法之外创建一个位图。我已经确定该图像是小的,不透明的,像素格式匹配...等等。当我不约10-15 FPS绘制帧率上升的形象。任何想法,以加快这?我经历了明显的滞后。
我创造一切外的位图...
私人位图bitmapPlayer = BitmapFactory.de codeResource(getResources(),R.drawable.player);
然后在我的onDraw()方法...
canvas.drawBitmap(bitmapPlayer,空,drawingRect,NULL); // drawingRect是矩形画里面的位图
// ...绘图code的休息
我只能假设你正在做的事情的逻辑沉重在你的绘制调用,如果你没有看到和下面的例子您code之间的任何差别
我将开始去看一看成以下,并利用你的绘图图形硬件。
希望这有助于
I am currently drawing a Bitmap
to a SurfaceView
using Canvas.drawBitmap()
. This seems to really reduce my framerate and I was wondering what I can do to fix this. I reference a bitmap that I have created outside the onDraw()
method. I have made sure that the image is small, opaque, the pixel formats match... etc. When I don't draw the image the framerate goes up by about 10-15 FPS. Any ideas to speed this up? I experience a noticeable lag.
I create the bitmap outside of everything...
private Bitmap bitmapPlayer = BitmapFactory.decodeResource(getResources(), R.drawable.player);
Then in my onDraw() method...
canvas.drawBitmap(bitmapPlayer, null, drawingRect, null); // drawingRect is the Rect to draw the Bitmap inside of
// ... Rest of drawing code
I can only assume you are doing something logic heavy in your draw call, If you don't see any differences between your code and the following example,
http://www.droidnova.com/playing-with-graphics-in-android-part-iii,176.html
I would start to take a look into the following, and utilizing the graphics hardware for your drawing.
http://developer.android.com/resources/articles/glsurfaceview.html
Hope this helps
这篇关于绘制一个位图作为背景SurfaceView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!