2 回答
![?](http://img1.sycdn.imooc.com/5458631e0001ffd402200220-100-100.jpg)
TA贡献2039条经验 获得超7个赞
如果您将文件路径存储在 SharedPrefence 中,那么您可以使用其路径将文件解码为位图。
File f = new File(file path....);
Bitmap map = BitmapFactory.decodeFile(f.getAbsolutePath());
image.setImageBitmap(map);
或者
String fileName = "...."; // file path
File completeFile = new File(fileName);
FileInputStream readPicture = new FileInputStream(completeFile);
BufferedInputStream bf = new BufferedInputStream(readPicture);
Bitmap bitmap = BitmapFactory.decodeStream(bf);
![?](http://img1.sycdn.imooc.com/545865da00012e6402200220-100-100.jpg)
TA贡献1843条经验 获得超7个赞
要从路径中获取位图,您需要使用下面的代码
File image = new File(mWinPhotoPath, imageName);
BitmapFactory.Options bmOptions = new BitmapFactory.Options();
Bitmap bitmap = BitmapFactory.decodeFile(image.getAbsolutePath(),bmOptions);
winImage = Bitmap.createScaledBitmap(bitmap,parent.getWidth(),parent.getHeight(),true);
添加回答
举报