android 保存bitmap到SD卡

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卡)