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; }
Android将Bitmap类型转化为file类型
最新推荐文章于 2023-04-18 14:15:48 发布