summaryrefslogtreecommitdiffstats
path: root/WallpaperPicker/src/com/android/gallery3d/common/BitmapUtils.java
diff options
context:
space:
mode:
Diffstat (limited to 'WallpaperPicker/src/com/android/gallery3d/common/BitmapUtils.java')
-rw-r--r--WallpaperPicker/src/com/android/gallery3d/common/BitmapUtils.java28
1 files changed, 7 insertions, 21 deletions
diff --git a/WallpaperPicker/src/com/android/gallery3d/common/BitmapUtils.java b/WallpaperPicker/src/com/android/gallery3d/common/BitmapUtils.java
index 9ac5c1bf7..6ddda87b5 100644
--- a/WallpaperPicker/src/com/android/gallery3d/common/BitmapUtils.java
+++ b/WallpaperPicker/src/com/android/gallery3d/common/BitmapUtils.java
@@ -21,8 +21,6 @@ import android.content.res.Resources;
import android.net.Uri;
import android.util.Log;
-import com.android.gallery3d.exif.ExifInterface;
-
import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;
@@ -42,38 +40,26 @@ public class BitmapUtils {
}
public static int getRotationFromExif(Context context, Uri uri) {
- return BitmapUtils.getRotationFromExifHelper(null, 0, context, uri);
+ return BitmapUtils.getRotationFromExifHelper(null, 0, uri, context);
}
- public static int getRotationFromExif(Resources res, int resId) {
- return BitmapUtils.getRotationFromExifHelper(res, resId, null, null);
+ public static int getRotationFromExif(Resources res, int resId, Context context) {
+ return BitmapUtils.getRotationFromExifHelper(res, resId, null, context);
}
- private static int getRotationFromExifHelper(Resources res, int resId, Context context, Uri uri) {
- ExifInterface ei = new ExifInterface();
+ private static int getRotationFromExifHelper(Resources res, int resId,
+ Uri uri, Context context) {
InputStream is = null;
- BufferedInputStream bis = null;
try {
if (uri != null) {
is = context.getContentResolver().openInputStream(uri);
- bis = new BufferedInputStream(is);
- ei.readExif(bis);
} else {
is = res.openRawResource(resId);
- bis = new BufferedInputStream(is);
- ei.readExif(bis);
- }
- Integer ori = ei.getTagIntValue(ExifInterface.TAG_ORIENTATION);
- if (ori != null) {
- return ExifInterface.getRotationForOrientationValue(ori.shortValue());
}
- } catch (IOException e) {
- Log.w(TAG, "Getting exif data failed", e);
- } catch (NullPointerException e) {
- // Sometimes the ExifInterface has an internal NPE if Exif data isn't valid
+ return ExifOrientation.readRotation(new BufferedInputStream(is), context);
+ } catch (IOException | NullPointerException e) {
Log.w(TAG, "Getting exif data failed", e);
} finally {
- Utils.closeSilently(bis);
Utils.closeSilently(is);
}
return 0;