From dd1b09c00fd6e07d85d3ba7f807dee207f84e154 Mon Sep 17 00:00:00 2001 From: mingwax Date: Thu, 19 Jan 2017 15:38:39 +0800 Subject: 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 --- src/com/android/camera/PhotoModule.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/com/android/camera/PhotoModule.java b/src/com/android/camera/PhotoModule.java index 5aa7a57ae..d808fa6bb 100644 --- a/src/com/android/camera/PhotoModule.java +++ b/src/com/android/camera/PhotoModule.java @@ -1262,13 +1262,18 @@ public class PhotoModule extends BaseModule 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 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); } } -- cgit v1.2.3