0

I think, the title is so specific. So, I want to explain first that I want to create a stamp application (like photobox) where we can put a lot of stamp images on the photo, save the image and the designs.

I am using option.inSampleSize in my code now. More likely this link : Strange out of memory issue while loading an image to a Bitmap object

This solved my problem when the image number is small. But when the image number (image count) is become larger out of memory exists again.

Is there any ideas from experts in here? Currently I'm still using ImageView to show the stamp images.

Or.. maybe there is no solution at this yet? The only thing that comes in my mind is to limit the number of images.

Community
  • 1
  • 1
user1383655
  • 195
  • 1
  • 10

1 Answers1

0

Have you followed the Google tutorial for image caching? It outlines the pitfalls and shows you how to properly cache the images so you do not exceed your memory budget.

Android Developer: Displaying Bitmaps - Cache Bitmap

The key lines would be

// Get memory class of this device, exceeding this amount will throw an
// OutOfMemory exception.
final int memClass = ((ActivityManager) context.getSystemService(
        Context.ACTIVITY_SERVICE)).getMemoryClass();

// Use 1/8th of the available memory for this memory cache.
final int cacheSize = 1024 * 1024 * memClass / 8;

mMemoryCache = new LruCache(cacheSize) {
    @Override
    protected int sizeOf(String key, Bitmap bitmap) {
        // The cache size will be measured in bytes rather than number of items.
        return bitmap.getByteCount();
    }
};
Orlymee
  • 2,349
  • 1
  • 22
  • 24
ian.shaun.thomas
  • 3,468
  • 25
  • 40