0

Possible Duplicate:
Android: Strange out of memory issue while loading an image to a Bitmap object

Bitmap bitmap = Bitmap.createBitmap(view.getWidth(),view.getHeight(),Bitmap.Config.ARGB_8888);

why this code throw exception: java.lang.OutOfMemoryError:bitmap size exceeds VM budget? I just get the width and height of the view which present on the screen. How can I solve the problem?

Community
  • 1
  • 1
Ryan.ye
  • 39
  • 1
  • 7

1 Answers1

0

Refer to this post

https://stackoverflow.com/a/823966/1441666

To fix OutOfMemory you should do something like that:

BitmapFactory.Options options=new BitmapFactory.Options();
options.inSampleSize = 8;
Bitmap preview_bitmap=BitmapFactory.decodeStream(is,null,options);

This inSampleSize option reduces memory consumption.

Community
  • 1
  • 1
Nirali
  • 13,571
  • 6
  • 40
  • 53