Getting this
05-25 23:55:59.145: ERROR/AndroidRuntime(3257): java.lang.OutOfMemoryError: bitmap size exceeds VM budget
at this code of min
hi @user418366 i was having the same problem when dealing with images what you can do is if you are using the emulator you can rise the max VM application Heap size so that you can get override of this problem or else as told by all try to compress the size of the image make sure that it was a loss less compression
I ran into a similar problem when selecting images from my EVO ... off the SD Card. The camera saves those images at over 1MB a piece, and in some cases close to 3 MB. Ironically, the size of the bitmap the Intent sends to you when "taking a picture" is only about 40 Kb.
The solution I came up with was:
BitmapFactory.Options options = new BitmapFactory.Options();
options.inSampleSize = 2; // this will cut the sampling by 50%
Bitmap bitmap = BitmapFactory.decodeFile( imageFilePath, options );
I was able to take pictures and cut them down to less than 100 Kb by increasing the factor number, and the images were still pretty good quality.
The bottom line here is it prevented OOME errors, and thus prevent me from crushing the JVM by exceeding the heap allocation. Simple - effective.
You might find this an interesting read also: BitmapFactory OOM driving me nuts
Android has a relatively limited amount of spare of memory for bitmaps (which can get smaller depending on what else is going on in the device). So the other answers are correct...
Check out Displaying a bitmap of arbitrary size without running out of memory for background on what's going on under the covers - which might help you avoid the OOM.
If the image is really big then you should just display the parts you need.
Make the bitmap smaller in resolution and potentially use a different file format..