android - GPS 标记在 android 中捕获的图像

标签 android image gps

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

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

我也用手机gps获取了经纬度

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

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

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

最佳答案

你不能将它设置为位图,位图只是一个带有图像像素的字节数组。 将其保存到支持元数据(例如 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();

关于android - GPS 标记在 android 中捕获的图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19023830/

相关文章:

c# - 如何比较两个不同的图像,通过tcp发送差异,然后将差异与客户端上的图像合并?

javascript - 在 Javascript 中预加载背景图片 - 无需事先声明 CSS

java - 不知道为什么 typeConvertor 不起作用

java - 在 Android 上停止轨道(在某个点)

javascript - 删除幻灯片之间的空白

android - 如何不断地将GPS数据从android发送到服务器直到应用程序关闭

android - 如何检查此人在哪里使用 gps。安卓

用于 GPS 服务的 Android 唤醒锁

android - 在android Translate-Animation中如何在另一个view2上方翻译view1,两个 View 以不同的布局退出

android - 我想从数据库中获取数据并将其显示在 ListView 上。