获取Bitmap保存到指定文件夹路径

xiaoxiao2021-02-28  91

需要将bitmap保存的时候直接调用,就行了。

public void saveMyBitmap(String bitName, Bitmap mBitmap) throws IOException {    File f = new File(Environment.getExternalStorageDirectory()+ "/Pictures/" + bitName + ".png"); f.createNewFile(); 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(); } }

转载请注明原文地址: https://www.6miu.com/read-74147.html

最新回复(0)