I'm building an android app that basically answer to touch events, when a touch event occurs I detect which action to perform and act upon it. The actions consists of display different bitmaps, so an action is, in fact, an animation:
- OnTouchEvent -> draw Bitmaps on SurfaceView
Normally 1 animation consist of around 20 - 30 images with size 28kbyte. As I need the app to be very responsive, I cannot allocate and deallocate memory on "per touch" basis so I wanted to have all the Bitmaps loaded (which should be around 12 MByte)
However when I reach around 0.5 MBytes of images loaded:
E/AndroidRuntime(10553): java.lang.OutOfMemoryError: bitmap size exceeds VM budget
E/AndroidRuntime(10553): at android.graphics.BitmapFactory.nativeDecodeByteArray(Native Method)
Over and over again.... any ideas ? Is it possible to draw images on Canvas without creating Bitmaps ? Can I convert my JPG files in Bitmaps without using BitmapFactory ? ( I read here: BitmapFactory OOM driving me nuts that the main issue is that Bitmap data uses the Native Heap instead of the VM Heap)
Any help much appreciated :D
Thanks in advance,
Ze