diff options
author | Ruben Brunk <rubenbrunk@google.com> | 2013-03-11 19:00:12 -0700 |
---|---|---|
committer | Ruben Brunk <rubenbrunk@google.com> | 2013-03-13 18:01:42 -0700 |
commit | 29fd4aa661f7e626a1d11558f09e8f7c011efcc2 (patch) | |
tree | c493ac90f0f3783e2efeea17083164a742cc621f /src/com/android/camera/Exif.java | |
parent | acca4ee0fefe6442b853510b6b360f6cb7ad1bc5 (diff) | |
download | android_packages_apps_Camera2-29fd4aa661f7e626a1d11558f09e8f7c011efcc2.tar.gz android_packages_apps_Camera2-29fd4aa661f7e626a1d11558f09e8f7c011efcc2.tar.bz2 android_packages_apps_Camera2-29fd4aa661f7e626a1d11558f09e8f7c011efcc2.zip |
Exif parser modifications.
Bug: 8018327
Change-Id: I66a2ec309f9807ac255bbf29d8f5f26de60e89b8
Diffstat (limited to 'src/com/android/camera/Exif.java')
-rw-r--r-- | src/com/android/camera/Exif.java | 45 |
1 files changed, 11 insertions, 34 deletions
diff --git a/src/com/android/camera/Exif.java b/src/com/android/camera/Exif.java index 605556599..ee39d675e 100644 --- a/src/com/android/camera/Exif.java +++ b/src/com/android/camera/Exif.java @@ -18,9 +18,7 @@ package com.android.camera; import android.util.Log; -import com.android.gallery3d.exif.ExifInvalidFormatException; -import com.android.gallery3d.exif.ExifParser; -import com.android.gallery3d.exif.ExifTag; +import com.android.gallery3d.exif.ExifInterface; import java.io.ByteArrayInputStream; import java.io.IOException; @@ -31,44 +29,23 @@ public class Exif { // Returns the degrees in clockwise. Values are 0, 90, 180, or 270. public static int getOrientation(byte[] jpeg) { - if (jpeg == null) return 0; + if (jpeg == null) { + return 0; + } + ExifInterface exif = new ExifInterface(); InputStream is = new ByteArrayInputStream(jpeg); - try { - ExifParser parser = ExifParser.parse(is, ExifParser.OPTION_IFD_0); - int event = parser.next(); - while(event != ExifParser.EVENT_END) { - if (event == ExifParser.EVENT_NEW_TAG) { - ExifTag tag = parser.getTag(); - if (tag.getTagId() == ExifTag.TAG_ORIENTATION && - tag.hasValue()) { - int orient = (int) tag.getValueAt(0); - switch (orient) { - case ExifTag.Orientation.TOP_LEFT: - return 0; - case ExifTag.Orientation.BOTTOM_LEFT: - return 180; - case ExifTag.Orientation.RIGHT_TOP: - return 90; - case ExifTag.Orientation.RIGHT_BOTTOM: - return 270; - default: - Log.i(TAG, "Unsupported orientation"); - return 0; - } - } - } - event = parser.next(); + exif.readExif(is); + Integer val = exif.getTagIntValue(ExifInterface.TAG_ORIENTATION); + if (val == null) { + return 0; + } else { + return ExifInterface.getRotationForOrientationValue(val.shortValue()); } - Log.i(TAG, "Orientation not found"); - return 0; } catch (IOException e) { Log.w(TAG, "Failed to read EXIF orientation", e); return 0; - } catch (ExifInvalidFormatException e) { - Log.w(TAG, "Failed to read EXIF orientation", e); - return 0; } } } |