如何显示内部存储中的位图?
我将位图图像保存在内部存储中,但无法重新显示它。我研究了很长时间但还没有找到。
public static void saveImages(Activity activity) throws IOException
{
for (int i=0; i<categories.getItems().length; i++) {
OutputStream os2 = activity.openFileOutput(categories.getItems()[i].getName(),
Context.MODE_WORLD_READABLE);
OutputStreamWriter osw2 = new OutputStreamWriter(os2);
Bitmap bmp = ((BitmapDrawable)categories.getItems()[i].getCategoryImage()).getBitmap();
bmp.compress(Bitmap.CompressFormat.PNG, 90, os2);
osw2.close();
}
}
此代码可以成功保存图像。我将重新显示文件中的图像。 谢谢
I saved my bitmap images in my internal storage but i can't redisplay it. I've been researching for a long time but i've not find yet.
public static void saveImages(Activity activity) throws IOException
{
for (int i=0; i<categories.getItems().length; i++) {
OutputStream os2 = activity.openFileOutput(categories.getItems()[i].getName(),
Context.MODE_WORLD_READABLE);
OutputStreamWriter osw2 = new OutputStreamWriter(os2);
Bitmap bmp = ((BitmapDrawable)categories.getItems()[i].getCategoryImage()).getBitmap();
bmp.compress(Bitmap.CompressFormat.PNG, 90, os2);
osw2.close();
}
}
This code works succesfully to save images. I will redisplay that images from files.
Thank you
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
试试这个
Try this
尝试以下代码:使用
openFileInput
获取您保存的流,然后对它们进行解码:Try this code: uses
openFileInput
to fetch the streams you saved and then decodes them:解码位图,然后创建一个新的imageView,然后将位图添加到imageView。
decode bitmap, and then make a new imageView then add the bitmap to the imageView.