Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android drawBitmap(...) method is slow?

I'm programming an Android game using SurfaceView.

The canvas obtained by the SurfaceView draws an 32bit PNG image of size 80x80 with alpha layer. The time that the method drawBitmap takes is 2-3ms.

Is this normal time for drawing such a small image or there is some implicit conversions happening behind the scene?

I have around 40 game objects (based on sprites) that should be drawn, and the time to draw all of them in one pass takes ~100ms. This is very slow and provides only 10FPS for a dynamic game. I tried many things, like turning off anti-aliasing, turning off the alpha, etc. but to no avail.

How should I go for optimizing the drawing time to get 25FPS at least?

Thanks, Zlatko

like image 369
Bart Avatar asked Nov 15 '22 01:11

Bart


1 Answers

I converted all PNG images to 8bit (they were 32bit) and now they are rendering very fast.

like image 147
Bart Avatar answered Dec 10 '22 16:12

Bart