BitmapFactory.de codeFILE(); [英] BitmapFactory.decodeFile();

查看:117
本文介绍了BitmapFactory.de codeFILE();的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的申请,我有一个文件:

In my application, I have a file:

private File TEMP_PHOTO_FILE = new File(Environment.getExternalStorageDirectory(), "temp_photo.jpg");

这是直接宣布在我的课,而且是可见的所有方法中存在

This is declared directly in my class, and is visible to all the methods there in.

我想用这个:

Bitmap thePhoto = BitmapFactory.decodeFile(Uri.fromFile(TEMP_PHOTO_FILE).toString());

Uri.fromFile(TEMP_PHOTO_FILE)的ToString()生成的字符串:文件:///mnt/sdcard/temp_photo.jpg

Uri.fromFile(TEMP_PHOTO_FILE).toString() generates the string: "file:///mnt/sdcard/temp_photo.jpg"

为什么这个不工作?看来,因为我们正在处理的文件,应该有一个接受URI作为输入德codeFILE()的某种方法。不允许,这是非常令人沮丧,由于不一致。

Why does this not work? It seems that since we're dealing with a file, there should be some method of decodeFile() that accepts a URI as input. Not allowing that is very frustrating due to the inconsistency.

推荐答案

文件://不起作用。试试这个:

"file://" doesn't work. Try this:

Bitmap thePhoto = BitmapFactory.decodeFile(TEMP_PHOTO_FILE.getAbsolutePath().toString());

这篇关于BitmapFactory.de codeFILE();的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆