skia : --- SkImageDecoder::Factory returned null
2016-04-27 21:16
459 查看
转载自:/article/10916304.html
写一个从uri load图片到imageView的功能,在从uri读取文件进行重新decode的时候出现了这个错误,困惑了半天,发现原来是inputStream引起的
网上有说inputStream.markSupported() 和 inputStream.reset() 搭配使用解决的,但是我没有成功。
写一个从uri load图片到imageView的功能,在从uri读取文件进行重新decode的时候出现了这个错误,困惑了半天,发现原来是inputStream引起的
public static Bitmap decodeUri(Context context, Uri uri, int reqWidth, int reqHeight) { InputStream input = null; Bitmap bitmap = null; try { input = context.getContentResolver().openInputStream(uri); BitmapFactory.Options o = new BitmapFactory.Options(); o.inJustDecodeBounds = true; BitmapFactory.decodeStream(input, null, o); input.close(); input = null; o.inSampleSize = calculateInSampleSize(o, reqWidth, reqHeight); // Decode bitmap with inSampleSize set o.inJustDecodeBounds = false; input = context.getContentResolver().openInputStream(uri);// 这个地方需要重新获取inputstream,不然就会出现如上错 bitmap = BitmapFactory.decodeStream(input, null, o); input.close(); input = null; } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); try { if(input != null) { input.close(); } } catch (IOException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } } return bitmap; }
网上有说inputStream.markSupported() 和 inputStream.reset() 搭配使用解决的,但是我没有成功。
相关文章推荐
- 线程面试题
- 在Mac中设置Ctrl+C/V进行复制/粘贴
- Qt之自定义提示框(类似QMessageBox)
- Volley
- 记录使用GitHub经历
- jquery.min.js一引入到工程中显示红叉
- Lock和synchronized的区别
- 阿里云服务器Ubuntu12.04_64bit+php5+MySQL部署过程详解
- 归并排序
- 后缀数组模版
- Qt 错误 The program has unexpectedly finished
- 站立会议(9)
- 第九次站立会议
- 泛型与Object
- centos7下mariadb 首次修改密码及忘记密码处理方法
- 说说写好的PHP代码如何在wampserver上怎么运行
- 局域网 广域网 城域网
- C++对象赋值与C#对象赋值----C++与C#值传递与引用传递浅析
- node log4js包
- 第八次站立会议