2 回答

TA貢獻(xiàn)2039條經(jīng)驗(yàn) 獲得超8個(gè)贊
如果您將文件路徑存儲(chǔ)在 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);

TA貢獻(xiàn)1843條經(jīng)驗(yàn) 獲得超7個(gè)贊
要從路徑中獲取位圖,您需要使用下面的代碼
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);
添加回答
舉報(bào)