【问题标题】:how can we store a bitmap image onto the mobile memory?我们如何将位图图像存储到移动内存中?
【发布时间】:2018-10-30 11:44:56
【问题描述】:

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

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

【问题讨论】:

  • 如果您正在寻找答案,请标记为答案。阿洛斯,下次发布您的代码。不要放你的代码图片。

标签: android android-camera android-bitmap android-internal-storage


【解决方案1】:

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

【讨论】:

  • 你不应该回答这样的坏问题!这将鼓励他们保持低质量并违反 SO 社区标准!
  • @Yahya 你说得对,我应该编辑他的问题。
猜你喜欢
  • 1970-01-01
  • 2014-01-17
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多