DRiFTy
DRiFTy

Reputation: 11369

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. 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?

Upvotes: 0

Views: 1374

Answers (2)

Andrew Seymour
Andrew Seymour

Reputation: 250

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

Upvotes: 0

Romain Guy
Romain Guy

Reputation: 98501

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.

Upvotes: 2

Related Questions