您的位置:首页 > 移动开发 > Android开发

android将Bitmap转换成文件

2015-11-30 10:26 555 查看
/**

* 将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;

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: