android - 为什么 BitmapFactory.decodeFile 返回 null?

标签 android imageview android-bitmap

我的代码:

BitmapFactory.Options opt = new BitmapFactory.Options();
opt.inJustDecodeBounds = true;
Bitmap rotateBmp = BitmapFactory.decodeFile("/storage/sdcard0/FastBurstCamera/2014-09-15 05-24-07-461.jpg", opt);

文件/storage/sdcard0/FastBurstCamera/2014-09-15 05-24-07-461.jpg存在,但rotateBmp为空,为什么?

最佳答案

The file /storage/sdcard0/FastBurstCamera/2014-09-15 05-24-07-461.jpg exists, but the rotateBmp is null, why?

因为这就是你所要求的。

引用the documentation for decodeFile() (强调):

The decoded bitmap, or null if the image data could not be decoded, or, if opts is non-null, if opts requested only the size be returned (in opts.outWidth and opts.outHeight)

引用the documentation for inJustDecodeBounds :

If set to true, the decoder will return null (no bitmap), but the out... fields will still be set, allowing the caller to query the bitmap without having to allocate the memory for its pixels.

关于android - 为什么 BitmapFactory.decodeFile 返回 null?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25994072/

相关文章:

android - 配置 eclipse 以提示 android xml 首选项的硬编码字符串

android - 如何在应用程序卸载之前永久保存数据(String 或 Int)

Android 4.4.2 x86 模拟器无法启动 - 卡在启动循环中

android - 如何将声音放入android动画中?

android - 当 setImageBitmap() 设置时,ImageView 不会显示图像

java - android ImageView 内存不足错误

java - Android/Java - 在位图底部绘制文本

android - QUERY_ALL_PACKAGES 是如何执行的?

java - 在 Canvas 顶部绘制多行文本

Android:位图的 LruCache 问题