1、将传入的Bitmap对象压缩并存储到本地文件中
try {
/*
通过Bitmap对象中compress函数实现将传入的bitmap图片进行压缩处理并写入到本地中
Bitmap.CompressFormat.JPEG 表示压缩后的图片格式,之所以选择jpeg格式作为图片的名称是因为该格式占用空间最小
100 表示压缩以后的图片质量,100表示质量最高
*/
bitmap.compress(Bitmap.CompressFormat.JPEG,100,new FileOutputStream(file1));
} catch (FileNotFoundException e) {
e.printStackTrace();
}
2、地区本地的图片并转换为Bitmap对象
try {
if (file.exists()){
//读取指定图片文件并将其转换为Bitmap对象
Bitmap bitmap1 = BitmapFactory.decodeStream(new FileInputStream(file));
return bitmap1;
}
} catch (FileNotFoundE