summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJack Yoo <jyoo@codeaurora.org>2016-09-23 18:18:15 (GMT)
committerArne Coucheron <arco68@gmail.com>2017-06-13 05:18:38 (GMT)
commitcc08b441ef6e94b95babc9f93420798bc6f52311 (patch)
treef049cc653d4af5bb14c274ce4bf3d8cda4eb4423
parentc188ffee66e30718a792bfccb581a9e630a1c4f1 (diff)
downloadandroid_packages_apps_Snap-cc08b441ef6e94b95babc9f93420798bc6f52311.zip
android_packages_apps_Snap-cc08b441ef6e94b95babc9f93420798bc6f52311.tar.gz
android_packages_apps_Snap-cc08b441ef6e94b95babc9f93420798bc6f52311.tar.bz2
SnapdragonCamera: Camera1 Selfie Mirror orientation check
Checking the case that front facing camera is 90 instead of 270. Change-Id: I75319db771057d64d1a21a1de825edd54af83982 CRs-Fixed: 1072060
-rw-r--r--src/com/android/camera/PhotoModule.java25
1 files changed, 20 insertions, 5 deletions
diff --git a/src/com/android/camera/PhotoModule.java b/src/com/android/camera/PhotoModule.java
index 2a902e2..5aa7a57 100644
--- a/src/com/android/camera/PhotoModule.java
+++ b/src/com/android/camera/PhotoModule.java
@@ -1262,10 +1262,14 @@ public class PhotoModule extends BaseModule<PhotoUI> implements
}
}
- private byte[] flipJpeg(byte[] jpegData) {
+ private byte[] flipJpeg(byte[] jpegData, int orientation) {
Bitmap srcBitmap = BitmapFactory.decodeByteArray(jpegData, 0, jpegData.length);
Matrix m = new Matrix();
- m.preScale(-1, 1);
+ if(orientation == 270) {
+ m.preScale(-1, 1);
+ } else { //if it's 90
+ m.preScale(1, -1);
+ }
Bitmap dstBitmap = Bitmap.createBitmap(srcBitmap, 0, 0, srcBitmap.getWidth(), srcBitmap.getHeight(), m, false);
dstBitmap.setDensity(DisplayMetrics.DENSITY_DEFAULT);
int size = dstBitmap.getWidth() * dstBitmap.getHeight();
@@ -1275,6 +1279,18 @@ public class PhotoModule extends BaseModule<PhotoUI> implements
return outStream.toByteArray();
}
+ public static byte[] addExifTags(byte[] jpeg, int orientationInDegree) {
+ ExifInterface exif = new ExifInterface();
+ exif.addOrientationTag(orientationInDegree);
+ ByteArrayOutputStream jpegOut = new ByteArrayOutputStream();
+ try {
+ exif.writeExif(jpeg, jpegOut);
+ } catch (IOException e) {
+ Log.e(TAG, "Could not write EXIF", e);
+ }
+ return jpegOut.toByteArray();
+ }
+
private final class JpegPictureCallback
implements CameraPictureCallback {
Location mLocation;
@@ -1415,9 +1431,8 @@ public class PhotoModule extends BaseModule<PhotoUI> implements
.findPreference(CameraSettings.KEY_SELFIE_MIRROR);
if (selfieMirrorPref != null && selfieMirrorPref.getValue() != null &&
selfieMirrorPref.getValue().equalsIgnoreCase("enable")) {
- jpegData = flipJpeg(jpegData);
- exif = Exif.getExif(jpegData);
- exif.addOrientationTag(orientation);
+ jpegData = flipJpeg(jpegData, info.orientation);
+ jpegData = addExifTags(jpegData, orientation);
}
}
if (!mIsImageCaptureIntent) {