保存位图Bitmap在SD卡

需求:将已选定或下载的Bitmap保存在SD卡

//保存Bitmap到SD卡
public void saveBitmap(Bitmap photo,String bmName) throws Exception 
{
            FileOutputStream fOut = null;
            try{ 
	       fOut = new FileOutputStream(Environment.getExternalStorageDirectory() + "/DCIM/"+bmName+".jpg"); 
            } catch (FileNotFoundException e) { 
                      // TODO Auto-generated catch block 
                        e.printStackTrace(); 
             } 
             photo.compress(Bitmap.CompressFormat.JPEG, 80, fOut); 
             try { 
	        fOut.flush(); 
	         fOut.close(); 
             } catch (IOException e) { 
	         // TODO Auto-generated catch block 
                         e.printStackTrace(); 
             }
		
    }
    

猜你喜欢

转载自luly20002003.iteye.com/blog/1628133
今日推荐