保存Bitmap图像

  1. /**  
  2.   * 保存文件  
  3.   * @param bm  
  4.   * @param fileName  
  5.   * @throws IOException  
  6.   */    
  7.  public void saveFile(Bitmap bm, String fileName) throws IOException {   
  8.   String path = getSDPath() +"/revoeye/";       
  9.      File dirFile = new File(path);    
  10.      if(!dirFile.exists()){    
  11.          dirFile.mkdir();    
  12.      }    
  13.      File myCaptureFile = new File(path + fileName);    
  14.      BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(myCaptureFile));    
  15.      bm.compress(Bitmap.CompressFormat.JPEG, 80, bos);    
  16.      bos.flush();    
  17.      bos.close();    
  18.  }  

posted on 2017-04-06 15:14  yaolunhui  阅读(153)  评论(0编辑  收藏  举报

导航