Monday, May 18, 2009

android bitmaps

In a new Android app I am developing I kept getting this error: "Exception bitmap size exceeds VM budget." The pictures wheren't bigger than some 400k, the error occurred after reading and discarding only three pictures. My solution is the following;

In my code, I resize the bitmap with

bitmap = Bitmap.createScaledBitmap(bitmap, 100, 150, false);

thinking I was smart recycling the same bitmap. As it turns out, using two different bitmaps solved my problem:

Bitmap bm = Bitmap.createScaledBitmap(bitmap, 100, 150, false);

No comments: