为 SurfaceView Android 绘制大位图背景

发布于 2025-01-03 03:16:26 字数 122 浏览 4 评论 0原文

我试图找到最好的方法(性能方面)将大型位图绘制到 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

熟人话多 2025-01-10 03:16:26

尝试使用不透明图像并将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.

爱冒险 2025-01-10 03:16:26

如果您的背景是静态的,那么您可以尝试将布局的背景设为背景图像。然后将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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文