else if(orientation == 0 && EXIF_ORIENTATION != 0) {
switch (EXIF_ORIENTATION) {
case 90:
orientation = ExifInterface.ORIENTATION_ROTATE_90;
degree = 90;
break;
case 180:
orientation = ExifInterface.ORIENTATION_ROTATE_180;
degree = 180;
break;
case 270:
orientation = ExifInterface.ORIENTATION_ROTATE_270;
degree = 270;
break;
}
exif.setAttribute(ExifInterface.TAG_ORIENTATION, Integer.toString(orientation));
try {
exif.saveAttributes();
} catch (IOException e) {
Log.e(TAG, "cannot save exif", e);
}
}
在应用层对于Exif的操作是通过android.media.ExifInterface接口完成的。
通过public void setAttribute (String tag, String value) 来设置,而获取可以通过 public int getAttributeInt (String tag, int defaultValue) 和 public String getAttribute (String tag) 两种方法都可以,getAttributeInt 重载方法一第二个参数为我们设置的默认值,如果成功则返回相应Tag的值;特定的整数内容为该方法直接返回值。而重载方法二该方法直接返回结果,如果失败则为null。
以上就是本文的全部内容,希望对大家的学习有所帮助。
注:相关教程知识阅读请移步到Android开发频道。










