如題,現在需要的是在imageView中顯示一個比較大的圖片(有幾M大)
inJustDecodeBounds這個我會用。
不過問題是出在這裡:
HttpMethod m_request;
......此處省略
m_request.getResponseBody();
獲取byte數組,這樣做,小圖會正常解析出Bitmap,對於大圖會報OOM.
然後我換了一種辦法:
m_responseStream = m_request.getResponseBodyAsStream();
BitmapFactory.Options opt = new BitmapFactory.Options();
opt.inJustDecodeBounds = true;
BitmapFactory.decodeStream(m_responseStream, null, opt);
...省略
opt.inJustDecodeBounds = false;
m_responseStream = m_request.getResponseBodyAsStream();
m_retBitmap = BitmapFactory.decodeStream(m_responseStream, null, opt);
這下不會OOM了,不過更蛋疼的來了:不管是大圖小圖返回全是null了。
http://bbs.csdn.net/topics/390760558