代码工作正常,但生成的图像失去了很多质量。使用的压缩格式是PNG。还有如何将图像保存为.png而不是.file。
public static void writeBitmapToDisk(String filename, Bitmap paramBitmap,
Context paramContext, Bitmap.CompressFormat paramCompressFormat) {
Log.e("CL", "paramBitmap.getByteCount()" + paramBitmap.getByteCount());
String str = constructFileName(filename);
if (paramBitmap != null) {
try {
FileOutputStream localFileOutputStream = paramContext
.openFileOutput(str, 0);
Log.e("CL", "localFileOutputStream" + localFileOutputStream);
paramBitmap.compress(paramCompressFormat, 100,
localFileOutputStream);
localFileOutputStream.close();
return;
} catch (FileNotFoundException localFileNotFoundException) {
localFileNotFoundException.printStackTrace();
return;
} catch (IOException localIOException) {
localIOException.printStackTrace();
}
}
}