好的,有人(离线)向我指出了一个有用的资源.在ExifInterface看起来像什么我正在寻找.Android-er有一篇文章演示了如何在Android中阅读EXIF元数据,我认为写作应该没有太大差异.
我不知道,但我们可以EXIF写任意元数据,即.不同于ExifInterface文档中指定的那些(如纬度,经度,闪光等).如果没有,那么将任意元数据写入图像文件的首选方法是什么?
谢谢
public static void writeFile (File photo, double latitude, double longitude) throws IOException{
ExifInterface exif = null;
try{
Log.v("latiDouble", ""+latitude);
Log.v("longiDouble", ""+longitude);
exif = new ExifInterface(photo.getCanonicalPath());
if (exif != null) {
double latitu = latitude;
double longitu = longitude;
double alat = Math.abs(latitu);
double along = Math.abs(longitu);
String stringLati = convertDoubleIntoDegree(alat);
String stringLongi = convertDoubleIntoDegree(along);
exif.setAttribute(ExifInterface.TAG_GPS_LATITUDE, stringLati);
exif.setAttribute(ExifInterface.TAG_GPS_LONGITUDE, stringLongi);
Log.v("latiString", ""+ stringLati);
Log.v("longiString", ""+ stringLongi);
exif.saveAttributes();
String lati = exif.getAttribute (ExifInterface.TAG_GPS_LATITUDE);
String longi = exif.getAttribute (ExifInterface.TAG_GPS_LONGITUDE);
Log.v("latiResult", ""+ lati);
Log.v("longiResult", ""+ longi);
}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
Run Code Online (Sandbox Code Playgroud)
我从这里复制了答案
| 归档时间: |
|
| 查看次数: |
15994 次 |
| 最近记录: |