【问题标题】:GPS tagged captured images in androidGPS标记在android中捕获的图像
【发布时间】:2013-09-26 17:12:28
【问题描述】:

我使用手机摄像头拍摄了一张照片并将其存储在变量“照片”中

Bitmap photo = (Bitmap) data.getExtras().get("data"); 

我也用手机gps得到了经纬度

lat = location.getLatitude();
lon = location.getLongitude();

如何将这个 gps 数据仅合并到图像中?

附:用户可以通过在相机设置中启用 GPS 标签选项来手动捕获带有 GPS 标签的图像。我想确保捕获的图像是强制 GPS 标记的。

【问题讨论】:

标签: android image gps


【解决方案1】:

您不能将其设置为位图,位图只是一个包含图像像素的字节数组。 将这些坐标保存到支持元数据的文件(例如 PNG 或 JPG)后,您必须应用这些坐标

为此,您可以使用ExifInterface

代码类似:

String filePath = Enviroment.getExternalStorageDirectory() + "/MyApp/photo.png";
OutputStream out = new BufferedOutputStream(new FileOutputStream(new File(filePath)));
photo.compress(Bitmap.CompressFormat.PNG, 100, out);
out.flush();
out.close();
ExifInterface exif = new ExifInterface(filePath);

// call this next setAttributes a few times to write all the GPS data to it.
exif.setAttribute(... );

// don't forget to save
exif.saveAttributes();

【讨论】:

    【解决方案2】:

    this 是您要找的吗?

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-05-17
      • 1970-01-01
      • 2013-07-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多