我从url加载图像。这是好的,但当它错误的时间很长,超出内存:位图大小超过虚拟机预算。下面是我的代码
BitmapFactory.Options bmOptions;
bmOptions = new BitmapFactory.Options();
bmOptions.inJustDecodeBounds = true;
//from web
try {
Bitmap bitmap=null;
InputStream is=new URL(url).openStream();
BitmapFactory.decodeStream(is, null, bmOptions);
is.close();
BitmapFactory.Options o2 = new BitmapFactory.Options();
o2.inSampleSize = 1;
is = new URL(url).openStream();
bitmap = BitmapFactory.decodeStream(is, null, o2);
is.close();
return bitmap;
} catch (Exception ex){
ex.printStackTrace();
return null;
}请帮帮我!!
发布于 2011-06-03 15:14:38
您的问题正是错误消息中所述:您的图像太大,无法加载到内存中。
https://stackoverflow.com/questions/6224086
复制相似问题