【发布时间】:2018-10-30 11:44:56
【问题描述】:
【问题讨论】:
-
如果您正在寻找答案,请标记为答案。阿洛斯,下次发布您的代码。不要放你的代码图片。
标签: android android-camera android-bitmap android-internal-storage
【问题讨论】:
标签: android android-camera android-bitmap android-internal-storage
1- 您必须找到要保存图像的路径。
2- 打开一个 OutputStream 对象并为其提供文件路径。
3- 将您的位图保存到输出流。
4- 冲洗。
5- 关闭。
// Get environment dir
String path = Environment.getExternalStorageDirectory().toString();
OutputStream fOut = null;
File file = new File(path, "MyImage"+".jpg"); // the File to save to
fOut = new FileOutputStream(file);
Bitmap pictureBitmap = BitmapFactory.decodeFile(imageFile.getAbsolutePath(), optons); // obtaining the Bitmap
pictureBitmap.compress(Bitmap.CompressFormat.JPEG, 100, fOut); // saving the Bitmap to a file compressed as a JPEG with 85% compression rate
fOut.flush(); // Not really required
fOut.close(); // do not forget to close the stream
【讨论】: