我在设备私有(private)存储中存储了一些图像,例如:
InputStream inputStream = response.getEntity().getContent();
FileOutputStream fileOutputStream = openFileOutput("someImage.jpeg", cont.MODE_PRIVATE);
int read = 0;
byte[] buffer = new byte[32768];
while((read = inputStream.read(buffer)) > 0) {
fileOutputStream.write(buffer, 0, read);
}
fileOutputStream.close();
inputStream.close();
然后我想读取该图像并将其存储为位图以将其显示给用户,我不知道该怎么做才能完成此任务!我想从私有(private)存储中再次读取图像,然后将其转换为位图。 有什么经验吗?
最佳答案
您需要的是BitmapFactory.decodeStream(String name)
.
首先,获取输入流:
InputStream input = openFileInput("someImage.jpeg");
接下来,用它来获取位图:
Bitmap bmp = BitmapFactory.decodeStream(input);
之后不要忘记关闭输入流!
关于android - 从私有(private)存储android读取图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28561964/