我从网络上获得的图像时,图像尺寸较大,我发现了以下错误如何从Android中加载url后缩小图像大小?
java.lang.OutOfMemoryError: bitmap size exceeds VM budget
我的代码如下我被使用LoadImageFromWebOperatins
方法加载图像。
animation.addFrame(LoadImageFromWebOperations(feed.getItem(i).getImage()), 2500);
animation.addFrame(LoadImageFromWebOperations(feed.getItem(i).getImage1()), 2500); animation.setOneShot(false);
iv.setBackgroundDrawable(animation);
iv.post(new Starter());
private Drawable LoadImageFromWebOperations(String url) {
try {
InputStream is = (InputStream) new URL(url).getContent();
Drawable d = Drawable.createFromStream(is, "src name");
return d;
} catch (Exception e) {
System.out.println("Exc=" + e);
return null;
}
}
在这种情况下,我该如何解决这个错误?请为此提供解决方案。
如果我保存在我的LoadImageFromWebOperations中,我收到错误。 –
什么错误?.... – ariefbayu
这是返回类型是可绘制的,但通过上面的代码,我会得到BitMap这会导致问题 –