BitmapFactory.decodeStream读取Asset文件出现decoder->decode returned false错误
来源:互联网 发布:房地产大数据分析 编辑:程序博客网 时间:2024/05/22 15:26
BitmapFactory.decodeStream(InputStream is)从Asset文件中读取图像文件时,会出现decoder->decode returned false错误,可能的问题之一是读取的文件类型为jpg格式的,将图片格式转码为gif格式即解决问题。
附1:读取Asset文件(以图像文件为例)的代码:
AssetManager am = ct.getResources().getAssets();//ct为Android的Activity传入到本class的应用程序的Context
String[] files_list= am.list("trained"); //将Asset文件夹内的"trained"文件夹内的所有的文加名列到files_list内
InputStream IS = am.open("trained/" + "file_name.gif"); //将Asset/trained文件夹内部的file_name.gif文件打开成InputStream 。
Bitmap bm = BitmapFactory.decodeStream(IS);
附2:读取网络文件到Bitmap
HttpClient httpClient = new DefaultHttpClient();
HttpResponse response = httpClient.execute(getMethod, new BasicHttpContext());
HttpEntity entity = response.getEntity();
InputStream is= entity.getContent();
Bitmap bm = BitmapFactory.decodeStream(is);
附3:其他解决decoder->decode returned false错误的链接
http://www.newsmth.net/nForum/#!article/MobileDev/38356
http://stackoverflow.com/questions/3802820/bitmapfactory-decodestream-always-returns-null-and-skia-decoder-shows-decode-ret
http://stackoverflow.com/questions/4339082/android-decoder-decode-returned-false-for-bitmap-download
http://stackoverflow.com/questions/11047224/unable-to-load-jpeg-image-with-bitmapfactory-decodefile-returns-null
http://android-developers.blogspot.com/2010/07/multithreading-for-performance.html
1 0
- BitmapFactory.decodeStream读取Asset文件出现decoder->decode returned false错误
- --- decoder->decode returned false
- 【Bitmap】亲测解决Bitmap出现 decoder->decode returned false 错误
- --- decoder->decode returned false 解决办法
- (求解答)decoder->decode returned false
- BitmapFactory.decodeStream方法返回null的错误分析
- BitmapFactory.decodeStream方法返回null的错误分析
- BitmapFactory.decodeStream()与BitmapFactory.decodeResource()
- BitmapFactory.decodeStream。报错:SkImageDecoder::Factory returned null 原因及解决方法
- BitmapFactory.decodeStream 问题
- BitmapFactory.decodeStream第二次无效
- BitmapFactory.decodeStream使用问题
- BitmapFactory.decodeStream返回null
- BitmapFactory.decodeStream第二次无效
- Android: BitmapFactory.decodeResource BitmapFactory.decodeStream区别
- 使用BitmapFactory出现outofmemory错误
- BitmapFactory.decodeStream方法OutOfMemoryError 解决方法
- Learning Python 015 Python3解决问题:读取文件时,出现乱码或者“UnicodeDecodeError 'gbk' codec can't decode” 错误
- 做你想做的工作 你也可以
- Mahout In Action中ItemCFHadoop流程图
- Centos修炼-----> Centos7之Centos安装NodeJs
- 关于Eclipse中main(String[] args)中参数配置的问题
- Enum 枚举详解
- BitmapFactory.decodeStream读取Asset文件出现decoder->decode returned false错误
- Android greenDao 使用教程(一)源码编译与使用
- TheanoGraphs排错
- java文件上传和下载 如何获取文件名称
- Visual Studio 2010中全局Directories的设置
- DHCP服务器配置
- SSH&Nutz框架使用定时器quartz
- Oracle安装完成 碰到的问题
- The Magic Tower