//3.保存Bitmap
try {
File path = new File(SavePath);
//文件
final String filepath = SavePath + System.currentTimeMillis() + ".png";
final File file = new File(filepath);
if (!path.exists()) {
path.mkdirs();
}
if (!file.exists()) {
file.createNewFile();
}
FileOutputStream fos = null;
fos = new FileOutputStream(file);
if (null != fos) {
bmp.compress(Bitmap.CompressFormat.PNG, 0, fos);
fos.flush();
fos.close();
bmp.compress(Bitmap.CompressFormat.PNG, 0, fos);可以設置對原圖片進行比例壓縮然後保存到本地。在此方法中,已將圖片流寫入fos。接下來只需刷新一下輸出流就可以了。