/**
* 将Bitmap转换成文件
* 保存文件
* @param bm
* @param fileName
* @throws IOException
*/
public static File saveFile(Bitmap bm,String path, String fileName) throws IOException {
File dirFile = new File(path);
if(!dirFile.exists()){
dirFile.mkdir();
}
File myCaptureFile = new File(path , fileName);
BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(myCaptureFile));
bm.compress(Bitmap.CompressFormat.JPEG, 80, bos);
bos.flush();
bos.close();
return myCaptureFile;
}
本文介绍了一种将Bitmap图像转换为指定路径下文件的方法,并详细解释了实现步骤,包括创建目录、构建目标文件、使用缓冲输出流进行压缩及保存。
5982

被折叠的 条评论
为什么被折叠?



