summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormingwax <mingwax@codeaurora.org>2017-01-19 15:38:39 +0800
committerArne Coucheron <arco68@gmail.com>2017-06-13 07:18:45 +0200
commitdd1b09c00fd6e07d85d3ba7f807dee207f84e154 (patch)
tree937b27c32eccdcddc1b134ac3f8cde806edec2e1
parentb37ea18e57aaa4492366b89065fb75ba6d067f2e (diff)
downloadandroid_packages_apps_Snap-dd1b09c00fd6e07d85d3ba7f807dee207f84e154.zip
android_packages_apps_Snap-dd1b09c00fd6e07d85d3ba7f807dee207f84e154.tar.gz
android_packages_apps_Snap-dd1b09c00fd6e07d85d3ba7f807dee207f84e154.tar.bz2
SnapdragonCamera: Fix photo reversed when enable selfie Mirror
When camera is open front camer, and is in horizontal screen mode enable Selfie Mirror, set the image rotation angle of 180 degrees, to ensure the picture is right direction. CRs-Fixed: 1112749 Change-Id: I9b53804b7897f174c537693ff59db96df858e71d
-rw-r--r--src/com/android/camera/PhotoModule.java11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/com/android/camera/PhotoModule.java b/src/com/android/camera/PhotoModule.java
index 5aa7a57..d808fa6 100644
--- a/src/com/android/camera/PhotoModule.java
+++ b/src/com/android/camera/PhotoModule.java
@@ -1262,13 +1262,18 @@ public class PhotoModule extends BaseModule<PhotoUI> implements
}
}
- private byte[] flipJpeg(byte[] jpegData, int orientation) {
+ private byte[] flipJpeg(byte[] jpegData, int orientation, int jpegOrientation) {
Bitmap srcBitmap = BitmapFactory.decodeByteArray(jpegData, 0, jpegData.length);
Matrix m = new Matrix();
if(orientation == 270) {
m.preScale(-1, 1);
} else { //if it's 90
- m.preScale(1, -1);
+ // Judge whether the picture or phone is horizontal screen
+ if (jpegOrientation == 0 || jpegOrientation == 180) {
+ m.preScale(-1, 1);
+ } else { // the picture or phone is Vertical screen
+ m.preScale(1, -1);
+ }
}
Bitmap dstBitmap = Bitmap.createBitmap(srcBitmap, 0, 0, srcBitmap.getWidth(), srcBitmap.getHeight(), m, false);
dstBitmap.setDensity(DisplayMetrics.DENSITY_DEFAULT);
@@ -1431,7 +1436,7 @@ 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, info.orientation);
+ jpegData = flipJpeg(jpegData, info.orientation, orientation);
jpegData = addExifTags(jpegData, orientation);
}
}