And*_*ndy 60 android bitmap out-of-memory
我正在从Url下载图像并显示它们.在下载时它正在给予out of memory error : bitmap size exceeds VM budget.我正在使用drawable.代码如下:
HttpClient httpclient= new DefaultHttpClient();
HttpResponse response=(HttpResponse)httpclient.execute(httpRequest);
HttpEntity entity= response.getEntity();
BufferedHttpEntity bufHttpEntity=new BufferedHttpEntity(entity);
InputStream instream = bufHttpEntity.getContent();
Bitmap bm = BitmapFactory.decodeStream(instream);
Bitmap useThisBitmap = Bitmap.createScaledBitmap(bm,bm.getWidth(),bm.getHeight(), true);
bm.recycle();
BitmapDrawable bt= new BitmapDrawable(useThisBitmap);
System.gc();
Run Code Online (Sandbox Code Playgroud)
这是错误: 05-28 14:55:47.251: ERROR/AndroidRuntime(4188): java.lang.OutOfMemoryError: bitmap size exceeds VM budget
San*_*ndo 31
使用decodeStream(is, outPadding, opts)与
BitmapFactory.Options opts=new BitmapFactory.Options();
opts.inDither=false; //Disable Dithering mode
opts.inPurgeable=true; //Tell to gc that whether it needs free memory, the Bitmap can be cleared
opts.inInputShareable=true; //Which kind of reference will be used to recover the Bitmap data after being clear, when it will be used in the future
opts.inTempStorage=new byte[32 * 1024];
Run Code Online (Sandbox Code Playgroud)
这个问题似乎已经被报道过好几次了,例如在这里和这里......对不起,Shalini,但如果是同样的问题,似乎根本没有解决方案......
Romain Guy 唯一的建议是使用更少的内存......
所以,祝你好运,以不同的方式思考你的事情......
| 归档时间: |
|
| 查看次数: |
60540 次 |
| 最近记录: |