【发布时间】:2013-03-10 01:56:56
【问题描述】:
我正在将图像复制到一个私有目录,如下所示:
FileChannel source = null;
FileChannel destination = null;
source = new FileInputStream(sourceFile).getChannel();
destination = new FileOutputStream(destFile).getChannel();
destination.transferFrom(source, 0, source.size());
source.close();
destination.close();
..但是当我稍后将它插入回画廊时,原封不动:
private void moveImageToGallery(Uri inUri) throws Exception {
MediaStore.Images.Media.insertImage(getContentResolver(), ImageUtil.loadFullBitmap(inUri.getPath()), null, null);
}
..它显然丢失了它的 Exif 数据。旋转不再起作用。有什么方法可以复制图像文件而不会丢失该数据?感谢您的任何建议。
【问题讨论】:
-
通过 Google Android 小组的探索让我相信这是一个操作系统问题,一位开发人员说,“似乎是一个有效的功能请求”。
-
这很难,没有一个好的方法可以做到这一点。您可以做的是在复制文件之后,在插入之前,使用 ExifInterface 添加您可以从图像数据库中读取的属性,例如旋转、纬度/经度和拍摄日期。然后,当您插入图像时,它应该正确读取这些图像并将它们添加到新的数据库条目中。哇,才发现这是2岁!我确定您已经做过类似的事情,但会在这里留下我的答案。不知道为什么它会出现在 Android 问题列表的顶部。