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.
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-mdpi are for screens with different densities (ldpi = low density, mdpi = medium density).
You can do the same with screen sizes:
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.
For more info about folder names and qualifiers: Android - Supporting Multiple Screens
1. if you scale all image according to screen size first and then draw on canvas
---> loading these bitmaps allocate memory and cause Grow Heap (bigger screen size = more memory allocation)
2. if you load all image without scale and scale framebuffer on draw
---> it make your FPS (frame per second) reduce and your game flickering (bigger screen size = more flicker)