我的bitmap
图像在bitmap
变量中,其名称是imageFile
我们如何进一步命名此bitmap
图像并将其存储在我的移动内存中
在这张图片中,一个函数显示接收图像文件并将其转换为bitmap
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