summaryrefslogtreecommitdiffstats
path: root/src/com/android/camera/ImageManager.java
diff options
context:
space:
mode:
authorChih-Chung Chang <chihchung@google.com>2009-09-22 05:04:34 +0800
committerChih-Chung Chang <chihchung@google.com>2009-09-22 08:34:38 +0800
commit7db0b4c11101ad215cfc33d645198a238ef6d4c2 (patch)
tree413ffdb18e1217c9a8913799b6ed00e33d1488a5 /src/com/android/camera/ImageManager.java
parent8a89877f74cf08d7b5f6342721b020a31a144529 (diff)
downloadLegacyCamera-7db0b4c11101ad215cfc33d645198a238ef6d4c2.zip
LegacyCamera-7db0b4c11101ad215cfc33d645198a238ef6d4c2.tar.gz
LegacyCamera-7db0b4c11101ad215cfc33d645198a238ef6d4c2.tar.bz2
Store orientation for pictures taken by Camera.
Diffstat (limited to 'src/com/android/camera/ImageManager.java')
-rw-r--r--src/com/android/camera/ImageManager.java30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/com/android/camera/ImageManager.java b/src/com/android/camera/ImageManager.java
index 45ffd26..e0a2093 100644
--- a/src/com/android/camera/ImageManager.java
+++ b/src/com/android/camera/ImageManager.java
@@ -33,6 +33,7 @@ import android.content.ContentValues;
import android.database.Cursor;
import android.graphics.Bitmap;
import android.location.Location;
+import android.media.ExifInterface;
import android.net.Uri;
import android.os.Environment;
import android.os.Parcel;
@@ -281,6 +282,35 @@ public class ImageManager {
ContentValues values = new ContentValues();
values.put(ImageColumns.MINI_THUMB_MAGIC, 0);
+ int degree = 0;
+ if (jpegData != null) {
+ ExifInterface exif = null;
+ try {
+ exif = new ExifInterface(filepath);
+ } catch (IOException ex) {
+ Log.e(TAG, "cannot read exif", ex);
+ }
+ if (exif != null) {
+ int orientation = exif.getAttributeInt(
+ ExifInterface.TAG_ORIENTATION, -1);
+ if (orientation != -1) {
+ // We only recognize a subset of orientation tag values.
+ switch(orientation) {
+ case ExifInterface.ORIENTATION_ROTATE_90:
+ degree = 90;
+ break;
+ case ExifInterface.ORIENTATION_ROTATE_180:
+ degree = 180;
+ break;
+ case ExifInterface.ORIENTATION_ROTATE_270:
+ degree = 270;
+ break;
+ }
+
+ }
+ }
+ }
+ values.put(Images.Media.ORIENTATION, degree);
cr.update(uri, values, null, null);
complete = true;
} finally {