简体   繁体   English

为SurfaceView Android绘制大型位图背景

[英]Drawing a Large Bitmap Background to SurfaceView Android

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. 我试图找到最好的方法(性能方面)将大型Bitmap绘制到Android中的SurfaceView作为静态背景图像。 I am currently just using the Canvas.drawBitmap() method but it brings my FPS down by a lot. 我目前只使用Canvas.drawBitmap()方法,但它使我的FPS下降了很多。 What are some ways that I can speed this up? 有什么方法可以加快这个速度?

Try to use an opaque image and set the Xfermode on the Paint to either null or PorterDuff.Mode.SRC. 尝试使用不透明图像并将Paint上的Xfermode设置为null或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的表面相同。

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: 然后将surfaceView背景显示为透明:

how to make surfaceview transparent 如何使surfaceview透明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM