Skip to content Skip to sidebar Skip to footer

Exception Picking A Image From Gallery (sd Card) For Use On My App... Java.lang.outofmemoryerror: Bitmap Size Exceeds Vm Budget

i am picking images on my app with android, and i dont know why, sometimes i got an exception, i think it's allways i select a image with more than 400 or 500 kb's but i am not sur

Solution 1:

Bitmap.createScaledBitmap method as long as I have researched has a highpoint of memory consumption and produces that error, but, I'm not totally sure about it. Anyway it is JAVA API and you cannot go deeper.

You can do the next:

//create a Drawable with your image asparameter
BitmapDrawable d=new BitmapDrawable(youBitmap);
//define bounds for your drawable       
intleft=0;
int top =0;
intright=80;
int bottom=80;

Rect r =new Rect(left,top,right,bottom);
//set the new bounds to your drawable       
d.setBounds(r);
//set the drawable asviewof your image view
profileImage.setImageDrawable(d); 

I have not tested this code, but it should work.

Post a Comment for "Exception Picking A Image From Gallery (sd Card) For Use On My App... Java.lang.outofmemoryerror: Bitmap Size Exceeds Vm Budget"