【发布时间】:2014-02-20 15:17:46
【问题描述】:
我们尝试将图像流解码为位图,但它返回空值。
来自本准则
URL aURL = new URL(url);
URLConnection conn = aURL.openConnection();
conn.connect();
InputStream is = conn.getInputStream();
BitmapFactory.Options options = new BitmapFactory.Options();
options.inJustDecodeBounds = true;
BitmapFactory.decodeStream(is, null, options);
options.inSampleSize = calculateInSampleSize(options, 768, 1280);
options.inJustDecodeBounds = false;
BufferedInputStream bis = new BufferedInputStream(is);
Bitmap bm = BitmapFactory.decodeStream(bis, options);
bis.close();
is.close();
我们得到原木猫
SkImageDecoder::Factory returned null
但是当我们只使用时
InputStream is = conn.getInputStream();
BufferedInputStream bis = new BufferedInputStream(is);
Bitmap bm = BitmapFactory.decodeStream(bis);
它工作正常。
【问题讨论】:
标签: android bitmap inputstream