When to scale bitmaps in android game

I've just started developing my first game with android using SurfaceView. I scale my bitmaps to support different screen sizes. But I don't know it's better to do the scaling when loading the bitmaps or when drawing them to canvas using Matrix. I guess the first one would occupy more memory but it's better in performance. But I don't know how really things work here so any suggestion from experts would be appreciated.

• What where the results of your performance tests which you surely did before opening this question? – Philipp Aug 13 '14 at 9:11
• Base on my test pre scaling result in a better FPS. But I don't know is it a good practice or not? @Philipp – Ali Aug 13 '14 at 9:14

Scaling of textures when rendering is generally not very performance intensive - it can sometimes even be faster to render small textures that are scaled up (usually when there are lots of textures and they need to be swapped from ram to vram). Of course, using small textures comes at the cost of quality.

It is generally best to avoid doing scaling yourself during runtime. If you want better quality for the textures then create multiple sets of textures (at varying resolutions) and determine the appropriate textures to load based on device resolution.

Android has special folders for this occasion, folders like drawable-ldpi and drawable-mdpi are for screens with different densities (ldpi = low density, mdpi = medium density).

You can do the same with screen sizes: drawable-normal or drawable-normal-ldpi

The plus side using this method is that when a user installs your app, only the images that are going to be used will be installed (since screen size or density can't physically change). This saves both memory and cpu.