Android学习笔记1_怎么把Bitmap对象存入SD卡中

来源:互联网 发布:淘宝售后客服好做吗 编辑:程序博客网 时间:2024/06/05 16:59

注:本人现从事android游戏开发。还属于菜鸟级别。写笔记主要为了积累一些知识点。以备以后开发时用到。若写到的一些知识点对你有用。尽管拿去。本人很乐于分享和交流的。呵呵。

Android中把Bitmap对象存入文件中的代码如下:

//获取sd卡的路径public  String filename=Environment.getExternalStorageDirectory().getPath()+"/huo.png";public  void savaBitmap(Bitmap bitmap){    File f = new File(filename);    FileOutputStream fOut = null;    try {    f.createNewFile();    fOut = new FileOutputStream(f);    } catch (Exception e) {    e.printStackTrace();    }    bitmap.compress(Bitmap.CompressFormat.PNG, 100, fOut);//把Bitmap对象解析成流    try {    fOut.flush();    fOut.close();    } catch (IOException e) {    e.printStackTrace();    }   
原创粉丝点击