summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEarl Ou <shunhsingou@google.com>2012-11-14 13:46:40 +0800
committerEarl Ou <shunhsingou@google.com>2012-11-14 17:07:31 +0800
commitb232a2caff083191ab9d24f0a164b9a83afafc1c (patch)
treec609044c59e05ded188a8deca864f8c638c4c13f
parentd6db57ca0d2b1c9ba554608fdfaabb9f2afb8ce0 (diff)
downloadandroid_packages_apps_Snap-b232a2caff083191ab9d24f0a164b9a83afafc1c.zip
android_packages_apps_Snap-b232a2caff083191ab9d24f0a164b9a83afafc1c.tar.gz
android_packages_apps_Snap-b232a2caff083191ab9d24f0a164b9a83afafc1c.tar.bz2
use ExifParser in ImageLoader
Change-Id: Ibcee97c15b2cc7df3aaa6c6c65535ca00cef2ed6
-rw-r--r--src/com/android/gallery3d/filtershow/cache/ImageLoader.java25
1 files changed, 22 insertions, 3 deletions
diff --git a/src/com/android/gallery3d/filtershow/cache/ImageLoader.java b/src/com/android/gallery3d/filtershow/cache/ImageLoader.java
index a891996..7874881 100644
--- a/src/com/android/gallery3d/filtershow/cache/ImageLoader.java
+++ b/src/com/android/gallery3d/filtershow/cache/ImageLoader.java
@@ -36,6 +36,9 @@ import com.adobe.xmp.XMPMeta;
import com.android.gallery3d.R;
import com.android.gallery3d.common.Utils;
+import com.android.gallery3d.exif.ExifInvalidFormatException;
+import com.android.gallery3d.exif.ExifParser;
+import com.android.gallery3d.exif.ExifTag;
import com.android.gallery3d.filtershow.FilterShowActivity;
import com.android.gallery3d.filtershow.HistoryAdapter;
import com.android.gallery3d.filtershow.imageshow.ImageCrop;
@@ -46,6 +49,7 @@ import com.android.gallery3d.util.XmpUtilHelper;
import java.io.Closeable;
import java.io.File;
+import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
@@ -153,12 +157,27 @@ public class ImageLoader {
static int getOrientationFromPath(String path) {
int orientation = -1;
+ InputStream is = null;
try {
- ExifInterface EXIF = new ExifInterface(path);
- orientation = EXIF.getAttributeInt(ExifInterface.TAG_ORIENTATION,
- 1);
+ is = new FileInputStream(path);
+ 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) {
+ orientation = (int) tag.getValueAt(0);
+ break;
+ }
+ }
+ event = parser.next();
+ }
} catch (IOException e) {
e.printStackTrace();
+ } catch (ExifInvalidFormatException e) {
+ e.printStackTrace();
+ } finally {
+ Utils.closeSilently(is);
}
return orientation;
}