-3

我的bitmap图像在bitmap变量中,其名称是imageFile我们如何进一步命名此bitmap图像并将其存储在我的移动内存中

在这张图片中,一个函数显示接收图像文件并将其转换为bitmap

在此处输入图像描述

4

1 回答 1

0

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
于 2018-05-20T19:03:20.217 回答