0
votes

In Application i need to load a few Bitmaps on create. To save Memory i'm loading one image, rescale it by creating a scaledBitmap out of it, recycle the unscaled Bitmap on so on:

    bmpUnscaled = BitmapFactory.decodeResource(getResources(), R.drawable.cultivation_plant_resized_1);
      plant1 = Bitmap.createScaledBitmap(bmpUnscaled,(int) plant[0].getWidth(), (int) plant[0].getHeight(), true);
      bmpUnscaled.recycle();
    System.gc();
    bmpUnscaled = BitmapFactory.decodeResource(getResources(), R.drawable.cultivation_plant_resized_2);
      plant2 = Bitmap.createScaledBitmap(bmpUnscaled,(int) plant[0].getWidth(), (int) plant[0].getHeight(), true);
      bmpUnscaled.recycle();
    System.gc();

and so on...

I am doing this 10 Images, wich are scaled relative to the screen resolution. The orginal Image is a PNG (570x900 (max. 660KB))

Does anybody have some Ideas to save Memory simply? I'm desperate right now...

1
Why do you say max 660kb? You no the difference between a file (e.g. PNG) and a bitmap loaded in memory? That image needs 2.5MB of heap space to load (570 x 900 x 4 bytes) - Simon

1 Answers

0
votes

Have you read: http://developer.android.com/training/displaying-bitmaps/load-bitmap.html?

The article contain great information about working with BitMap.