GPS标记在机器人拍摄的图像 [英] GPS tagged captured images in android

查看:91
本文介绍了GPS标记在机器人拍摄的图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已抓获使用手机相机拍摄照片并将其存储在变量照片

I have captured a picture using the phone camera and stored it in variable "photo"

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

我已使用电话的GPS还获得的纬度和经度

I have also obtained the latitude and longitude using the phone gps

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

我如何把这种GPS数据的图像只?

How do I incorporate this gps data in the image only?

P.S。 GPS标记的图像可以手动通过启用用户的相机设置GPS的标签选项被捕获。我想,以确保所拍摄的图像是强制GPS标记。

P.S. GPS tagged images can be captured manually by enabling the GPS tag option in the camera settings by the user. I want to make sure that the image captured is compulsorily GPS tagged.

推荐答案

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

you can't set it to the Bitmap, the Bitmap is just a byte array with the image pixels. You have to apply those coordinates after you save it to a file that supports Metadata (for example PNG or JPG)

要做到这一点,你使用 ExifInterface

To do that you use the ExifInterface

code是类似于

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();

这篇关于GPS标记在机器人拍摄的图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆