diff options
author | Angus Kong <shkong@google.com> | 2013-03-26 11:40:40 -0700 |
---|---|---|
committer | Angus Kong <shkong@google.com> | 2013-03-26 15:42:36 -0700 |
commit | 0d00a8907096b9970ac64f52abbd2bfc1ed751b6 (patch) | |
tree | bd92779ff5810d46128c0f11a7a84c78ad52d35f /src/com/android/camera/Exif.java | |
parent | 88efa27609d08a749cda7ba928cb825de71a7f2b (diff) | |
download | android_packages_apps_Snap-0d00a8907096b9970ac64f52abbd2bfc1ed751b6.tar.gz android_packages_apps_Snap-0d00a8907096b9970ac64f52abbd2bfc1ed751b6.tar.bz2 android_packages_apps_Snap-0d00a8907096b9970ac64f52abbd2bfc1ed751b6.zip |
Add GPSDirection tag using ExifInterface.
bug:8115825
Change-Id: Iefcbbddbb7f9fed0c386214b428d4743f67d0dd9
Diffstat (limited to 'src/com/android/camera/Exif.java')
-rw-r--r-- | src/com/android/camera/Exif.java | 37 |
1 files changed, 20 insertions, 17 deletions
diff --git a/src/com/android/camera/Exif.java b/src/com/android/camera/Exif.java index ee39d675e..c6ec6af50 100644 --- a/src/com/android/camera/Exif.java +++ b/src/com/android/camera/Exif.java @@ -20,32 +20,35 @@ import android.util.Log; import com.android.gallery3d.exif.ExifInterface; -import java.io.ByteArrayInputStream; import java.io.IOException; -import java.io.InputStream; public class Exif { private static final String TAG = "CameraExif"; - // Returns the degrees in clockwise. Values are 0, 90, 180, or 270. - public static int getOrientation(byte[] jpeg) { - if (jpeg == null) { - return 0; - } - + public static ExifInterface getExif(byte[] jpegData) { ExifInterface exif = new ExifInterface(); - InputStream is = new ByteArrayInputStream(jpeg); try { - exif.readExif(is); - Integer val = exif.getTagIntValue(ExifInterface.TAG_ORIENTATION); - if (val == null) { - return 0; - } else { - return ExifInterface.getRotationForOrientationValue(val.shortValue()); - } + exif.readExif(jpegData); } catch (IOException e) { - Log.w(TAG, "Failed to read EXIF orientation", e); + Log.w(TAG, "Failed to read EXIF data", e); + } + return exif; + } + + // Returns the degrees in clockwise. Values are 0, 90, 180, or 270. + public static int getOrientation(ExifInterface exif) { + Integer val = exif.getTagIntValue(ExifInterface.TAG_ORIENTATION); + if (val == null) { return 0; + } else { + return ExifInterface.getRotationForOrientationValue(val.shortValue()); } } + + public static int getOrientation(byte[] jpegData) { + if (jpegData == null) return 0; + + ExifInterface exif = getExif(jpegData); + return getOrientation(exif); + } } |