private void saveBitmap(Bitmap bitmap){
File file = new File(Environment.getExternalStorageDirectory() + "/test.png");
if (!file.exists()) {
try {
file.createNewFile();
} catch (IOException e) {
e.printStackTrace();
}
}
try {
FileOutputStream out = new FileOutputStream(file);
bitmap.compress(Bitmap.CompressFormat.PNG, 100, out);
out.flush();
out.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
Android保存bitmap到本地
最新推荐文章于 2024-08-18 02:54:59 发布