BitmapFactory.decodeStream。报错:SkImageDecoder::Factory returned null 原因及解决方法
来源:互联网 发布:算法统宗校释 编辑:程序博客网 时间:2024/04/30 07:48
最近在写一个相机调用相册的图片,显示到桌面的View上,BitmapFactory.decodeStream 调用了 结果报错了SkImageDecoder::Factory returned nul。
废话不多说,来上我自己的代码。
if(resultCode==RESULT_OK){try {Bitmap bitmap=BitmapFactory.decodeStream(getContentResolver().openInputStream(imageUri));picture.setImageBitmap(bitmap);} catch (FileNotFoundException e) {// TODO Auto-generated catch blocke.printStackTrace();}}
看了很多博客,还是不太明白,看了源代码好像明白了。
下面是BitmapFactory.decodeStream 的SDK源代码
public static Bitmap decodeStream(InputStream is, Rect outPadding, Options opts) { // we don't throw in this case, thus allowing the caller to only check // the cache, and not force the image to be decoded. if (is == null) { return null; } // we need mark/reset to work properly if (!is.markSupported()) { is = new BufferedInputStream(is, 16 * 1024); } // so we can call reset() if a given codec gives up after reading up to // this many bytes. FIXME: need to find out from the codecs what this // value should be. is.mark(1024);
用中文解释下
1、当is这个inputstream为空时,我们不抛出异常。因此仅允许调用者检查缓存,不强制把图片解码。
2、我们需要标记和重置来让解析图片这个工作更恰当
3、所以,当读取的字节到1024(1kb)时,解码器停止解码,之后我们调用重置方法。
注:is.mark(1024),这个方法是写死的。即当图片超过1kb,我们解析到1kb的时候,然后重置,就会抛出异常。
解决方法:使用BitmapFactory.decodebyteArrays 或者 BitmapFactory.Options
1 0
- BitmapFactory.decodeStream。报错:SkImageDecoder::Factory returned null 原因及解决方法
- SkImageDecoder::Factory returned null
- SkImageDecoder::Factory returned null
- SkImageDecoder::Factory returned null
- SkImageDecoder::Factory returned null
- SkImageDecoder::Factory returned null
- Android SkImageDecoder::Factory returned null
- Android: SkImageDecoder:: Factory returned null
- skia : --- SkImageDecoder::Factory returned null
- skia : --- SkImageDecoder::Factory returned null
- 关于异常:SkImageDecoder::Factory returned null
- BitmapFactory.decodeStream返回null
- Android加载图片出现SKImagedecoder::Factory returned null 该怎么解决
- 读取网络图片和本地sd卡图片文件 解析为空 SkImageDecoder::Factory returned null
- BitmapFactory.decodeStream方法OutOfMemoryError 解决方法
- BitmapFactory.decodeStream 报错OUT OF MEMORY ERROR
- 解决android BitmapFactory.decodeStream()返回null
- Android BitmapFactory.decodeStream方法OutOfMemoryError 解决方法
- MyBatis之传入参数
- Android性能优化策略
- android 游戏 实战打飞机游戏 BOSS的设计 以及胜利失败页面(6结束)
- [从头学数学] 第231节 不定积分
- java数组和集合复习
- BitmapFactory.decodeStream。报错:SkImageDecoder::Factory returned null 原因及解决方法
- poj1942求组合数
- iOS 自定义分区头加上图片 以及导航控制器 颜色随滑动改变
- HDU - 4006 The kth great number (set&数据结构)
- SpringMVC 获得应用的绝对路径
- 如何使用libcurl实现HTTP的GET方法获取文件长度
- json解析
- Android自定义控件+popuwindow下拉菜单的实现仿58下拉菜单
- ANR traces分析 系统一直出现 waiting for ...日志