Am getting Exception error when loading images from assets to arraylist. this is the error in log cat: E/AndroidRuntime(2837): java.lang.OutOfMemoryError: bitmap size exceeds VM budget
Please some one help me with this,Thanks in advance
Am getting Exception error when loading images from assets to arraylist. this is the error in log cat: E/AndroidRuntime(2837): java.lang.OutOfMemoryError: bitmap size exceeds VM budget
Please some one help me with this,Thanks in advance
Once, i tried to re-size the image, i' also having the same problem, i used the below code, you can modify as it yours,
public Bitmap custom_SizedImage(String intent_data2) {
Options options = new Options();
options.inJustDecodeBounds = true;
BitmapFactory.decodeFile(intent_data2, options);
double sampleSize = 0;
Boolean scaleByHeight = Math.abs(options.outHeight - targetHeight) >= Math
.abs(options.outWidth - targetWidth);
if (options.outHeight * options.outWidth * 2 >= 1638) {
sampleSize = scaleByHeight ? options.outHeight / targetHeight
: options.outWidth / targetWidth;
sampleSize = (int) Math.pow(2d,
Math.floor(Math.log(sampleSize) / Math.log(2d)));
}
options.inJustDecodeBounds = false;
options.inTempStorage = new byte[128];
while (true) {
try {
options.inSampleSize = (int) sampleSize;
// here you can do you Decode process
//mBitmap = BitmapFactory.decodeFile(intent_data2, options);
break;
} catch (Exception ex) {
try {
sampleSize = sampleSize * 2;
} catch (Exception ex1) {
}
}
}
return scaledBitmap;
}