如何显示从内部存储位图? [英] How to display bitmap from internal storage?

查看:181
本文介绍了如何显示从内部存储位图?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我救了我的位图图像在我的内部存储空间,但我不能重新显示。我已经研究了很长时间,但我一直没找到呢。

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();
        }
    }

这code ++工程,成功地保存图像。我会重新显示该图片来自文件。
谢谢

This code works succesfully to save images. I will redisplay that images from files. Thank you

推荐答案

试试这个code:使用 openFileInput 来获取保存的数据流,然后去codeS他们:

Try this code: uses openFileInput to fetch the streams you saved and then decodes them:

for (int i=0; i<categories.getItems().length; i++) {        
InputStream is = activity.openFileInput(categories.getItems()[i].getName());
Bitmap b = BitmapFactory.decodeStream(is);

// do whatever you need with b
}

这篇关于如何显示从内部存储位图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆