Search code examples
androidimagebitmapout-of-memorysave-image

Saving shapes on top of large images


I'm creating somekind of 2D image editor in Android and I have the big problem of big files don't fit in memory.

I need to zoom in/out the image put some shapes and then save it.

My question is:

How can I load the image and save it without getting out of memory? I've been reading about bitmapregiondecode and the sample technic but there's must be another solution. How can I save the image if I always use regiondecode?

The images need good detail quality because it's architectural images... and the lines must be well defined.

I'm new to this, help me please.


Solution

  • Note two things while dealing with images:

    tempBitmap = Bitmap.createBitmap(bit);

    clone the bitmap which you are using for zoom and other operations but wont use the original because it looses its clarity when you save;

    when done with bitmap give
    bit.recycle(); to release the memory space