Skip to content Skip to sidebar Skip to footer

Avoiding Out Of Memory Exception In Applying Filters To Images (android)

I am trying to apply some filters on a Image. To apply the filter, i have to first create an array: int[] arr = new int[image.width*image.height];// to store each pixel and then i

Solution 1:

try using largeHeap in manifest.xml under application tag add

android:largeHeap = "true"

Solution 2:

best way to handle really large images is to use JNI .

maybe renderscript can also help, but i'm not sure about its memory limitations.

Solution 3:

One way to handle this is to tile the image, like you suggested. Catch the OOME, and keep halving the size of your tiles until the array allocates successfully.

Then process each tile sequentially, re-using the array each time.

Solution 4:

To answer your question, i would consider it in two different parts.

  1. how to avoid out of memory exceptions... you can refer to this link. There is my answer.

  2. Second is if you wanna show image that is as big as 5 MB. You can try having a buffer storage. download image in chunks one by one, save them to temp file and keep clearing the buffer storage. I haven't implemented it myself. you can give it a try.

Thanks: N_JOY

Post a Comment for "Avoiding Out Of Memory Exception In Applying Filters To Images (android)"