我目前正在使用 Canvas.drawBitmap()
将 Bitmap
绘制到 SurfaceView
。这似乎真的降低了我的帧率,我想知道我能做些什么来解决这个问题。我引用了我在 onDraw()
方法之外创建的位图。我已确保图像很小、不透明、像素格式匹配...等等。当我不绘制图像时,帧率会上升大约 10-15 FPS。有什么想法可以加快速度吗?我遇到了明显的延迟。
我在一切之外创建位图...
private Bitmap bitmapPlayer = BitmapFactory.decodeResource(getResources(), R.drawable.player);
然后在我的 onDraw() 方法中...
canvas.drawBitmap(bitmapPlayer, null, drawingRect, null); // drawingRect is the Rect to draw the Bitmap inside of
// ... Rest of drawing code
最佳答案
我只能假设您在绘图调用中做了一些逻辑繁重的事情,如果您没有发现您的代码与以下示例之间有任何差异,
http://www.droidnova.com/playing-with-graphics-in-android-part-iii,176.html
我会开始研究以下内容,并利用图形硬件进行绘图。
http://developer.android.com/resources/articles/glsurfaceview.html
希望对你有帮助
关于java - 绘制位图作为 SurfaceView 背景,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9201002/