将Bitmap类型的图片转化成file类型,便于上传到服务器
public File saveFile(Bitmap bm, String fileName) throws IOException {//将Bitmap类型的图片转化成file类型,便于上传到服务器
String path = Environment.getExternalStorageDirectory() + "/Ask";
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;
}
————————————————
版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
原文链接:https://blog.csdn.net/hxy19971101/article/details/76376682