2012-07-24 78 views
0

Possible Duplicate:
Android: Strange out of memory issue while loading an image to a Bitmap objectAndroid的位图的大小超过VM预算

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

为什么这个代码抛出异常:java.lang.OutOfMemoryError:位图大小超过VM预算? 我只是得到了在屏幕上呈现的视图的宽度和高度。 我该如何解决这个问题?

+0

http://stackoverflow.com/a/823966/1075066先尝试谷歌.. – 2012-07-24 07:41:29

回答

0

参阅这篇

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

要解决内存不足,你应该做这样的事情:

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

这inSampleSize选项可减少内存消耗。

相关问题