保存文件:BitmapFactory.decodeFile返回null即使图像中存在
FileOutputStream fo = null;
try {
fo = this.openFileOutput("test.png", Context.MODE_WORLD_READABLE);
} catch (FileNotFoundException e) {
e.printStackTrace();
}
bitmap.compress(CompressFormat.PNG, 100, fo)
加载文件:
String fname = this.getFilesDir().getAbsolutePath()+"/test.png";
Bitmap bMap = BitmapFactory.decodeFile(fname);
i.setImageBitmap(bMap);
最后一行给出了一个空指针异常,为什么BitmapFactory.decodeFile返回null?我可以验证文件是否正确保存,因为我可以使用adb将其拉出,并看到png正确显示。
你关闭了文件输出流吗?什么是“我”设置,为什么它有一个单一的字符名称? – Douglas 2010-08-02 14:53:40
是的,它已关闭。我是一个图像视图,它被设置为空,因为我不正确地引用它。 – stealthcopter 2010-08-02 16:09:32