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

来源:互联网 发布:qq三国活力涨不停算法 编辑:程序博客网 时间:2024/05/28 16:22


需要将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();
}
}

阅读全文
0 0
原创粉丝点击