Reputation: 13
I had a look for outofmemory exception questions but I couldn't find out a way for my problem. I have an application which processes images. I need to get RGB values of each pixel of the image. I can do it when I choose image from whatsapp file because they have small size but if I want to choose images from gallery(taken via camera) or if I want to take photo from camera directly I have outofmemeory exception. I don't want to scale down image because I need all pixels' information of the image.
I have the file and name information of the image as a string, I get this exception when I decode the string as shown below;
imgDecodableString = intent3.getStringExtra("BMP");
rotatedBitmap = BitmapFactory.decodeFile(imgDecodableString);
Is there any way to handle this problem? Thanks in advance .
Upvotes: 0
Views: 329
Reputation: 11
you must convert the high resolution of your drawable image to: drawable-xxhdpi. and add: android:largeHeap="true" on androidManifest.xml inside application tag
I have solved my OutOfMemory problem by using this method
Upvotes: 0
Reputation: 229
If you don't want to scale down the image, you can use BitmapRegionDecoder to decode each part of the image and process the bitmap instead of decode whole the image.
Upvotes: 0
Reputation: 294
If You use this line of code in Manifest file in application tag the Outofmemory exception will solve try this.
android:largeHeap="true"
Upvotes: 1