diff options
author | Sascha Haeberling <haeberling@google.com> | 2013-08-08 11:27:09 -0700 |
---|---|---|
committer | Sascha Haeberling <haeberling@google.com> | 2013-08-08 18:31:53 -0700 |
commit | 723bf81990245a07739146ac10357703c9839de1 (patch) | |
tree | 0c86a8a133077db5191907a760d5f4b3ab441b77 /src/com/android/gallery3d/data/Exif.java | |
parent | a6b80cccafe0a4c2de575ec69d1960c3c0d88062 (diff) | |
download | android_packages_apps_Gallery2-723bf81990245a07739146ac10357703c9839de1.tar.gz android_packages_apps_Gallery2-723bf81990245a07739146ac10357703c9839de1.tar.bz2 android_packages_apps_Gallery2-723bf81990245a07739146ac10357703c9839de1.zip |
Remove Camera from Gallery2.
Change-Id: I89adebffcacd1269217d7bd8c630c2f78886f590
Diffstat (limited to 'src/com/android/gallery3d/data/Exif.java')
-rw-r--r-- | src/com/android/gallery3d/data/Exif.java | 44 |
1 files changed, 42 insertions, 2 deletions
diff --git a/src/com/android/gallery3d/data/Exif.java b/src/com/android/gallery3d/data/Exif.java index 950e7de18..20f072454 100644 --- a/src/com/android/gallery3d/data/Exif.java +++ b/src/com/android/gallery3d/data/Exif.java @@ -24,9 +24,11 @@ import java.io.IOException; import java.io.InputStream; public class Exif { - private static final String TAG = "CameraExif"; + private static final String TAG = "GalleryExif"; - // Returns the degrees in clockwise. Values are 0, 90, 180, or 270. + /** + * Returns the degrees in clockwise. Values are 0, 90, 180, or 270. + */ public static int getOrientation(InputStream is) { if (is == null) { return 0; @@ -45,4 +47,42 @@ public class Exif { return 0; } } + + /** + * Returns an exif interface instance for the given JPEG image. + * + * @param jpegData a valid JPEG image containing EXIF data + */ + public static ExifInterface getExif(byte[] jpegData) { + ExifInterface exif = new ExifInterface(); + try { + exif.readExif(jpegData); + } catch (IOException 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()); + } + } + + /** + * See {@link #getOrientation(byte[])}, but using the picture bytes instead. + */ + public static int getOrientation(byte[] jpegData) { + if (jpegData == null) + return 0; + + ExifInterface exif = getExif(jpegData); + return getOrientation(exif); + } } |