码迷,mamicode.com
首页 > 移动开发 > 详细

android 保存bitmap到SD卡

时间:2015-04-01 00:32:38      阅读:137      评论:0      收藏:0      [点我收藏+]

标签:

public void saveMyBitmap(String bitName,Bitmap mBitmap){
  File f = new File("/sdcard/" + bitName + ".png");
  try {
   f.createNewFile();
  } catch (IOException e) {
   // TODO Auto-generated catch block
   DebugMessage.put("在保存图片时出错:"+e.toString());
  }
  FileOutputStream fOut = null;
  try {
   fOut = new FileOutputStream(f);
  } catch (FileNotFoundException e) {
   e.printStackTrace();
  }
  mBitmap.compress(Bitmap.CompressFormat.PNG, 100, fOut);
  try {
   fOut.flush();
  } catch (IOException e) {
   e.printStackTrace();
  }
  try {
   fOut.close();
  } catch (IOException e) {
   e.printStackTrace();
  }
 }

android 保存bitmap到SD卡

标签:

原文地址:http://my.oschina.net/airship/blog/394419

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!