public void saveBitmap(Bitmap bm, String path) { String dir = path.substring(0,path.lastIndexOf("/")); File dirFile = new File(dir); if (!dirFile.exists()) { dirFile.mkdirs(); } File f = new File(path); if (f.exists()) { f.delete(); } FileOutputStream out = null; try { out = new FileOutputStream(f); bm.compress(Bitmap.CompressFormat.JPEG, 100, out); } catch (FileNotFoundException e) { e.printStackTrace(); } finally { if (out != null) { try { out.flush(); out.close(); } catch (IOException e) { e.printStackTrace(); } } } }
将bitmap保存为文件
猜你喜欢
转载自n-wang.iteye.com/blog/2339897
今日推荐
周排行