为 SurfaceView Android 绘制大位图背景
我试图找到最好的方法(性能方面)将大型位图绘制到 Android 中的 SurfaceView 作为固定背景图像。我目前只使用 Canvas.drawBitmap() 方法,但它使我的 FPS 下降了很多。有哪些方法可以加快速度?
I am trying to find the best way (preformance-wise) to draw a large Bitmap
to a SurfaceView
in Android as a stationary background image. I am currently just using the Canvas.drawBitmap()
method but it brings my FPS down by a lot. What are some ways that I can speed this up?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
尝试使用不透明图像并将Paint 上的Xfermode 设置为null 或PorterDuff.Mode.SRC。这将禁用混合,这可能会很昂贵。还要确保您的图像没有拉伸(没有缩放),并且它的格式与表面视图的表面相同。
Try to use an opaque image and set the Xfermode on the Paint to either null or PorterDuff.Mode.SRC. This will disable blending which can be expensive. Also make sure your image is not stretched (no scaling) and that it's in the same format as the surfaceview's surface.
如果您的背景是静态的,那么您可以尝试将布局的背景设为背景图像。然后将surfaceView背景设置为透明:
如何使surfaceview透明
If your background is going to be static, then you could try making the background of your layout the background image. Then put the surfaceView background as transparent:
how to make surfaceview transparent