OSDN Git Service

Fix a bug that captured image in review is rotated
authorSheng-Hao Tsao <shenghao@google.com>
Wed, 12 Oct 2016 09:36:44 +0000 (18:36 +0900)
committerSheng-hao Tsao <shenghao@google.com>
Wed, 19 Oct 2016 02:47:20 +0000 (02:47 +0000)
If the default camera app is triggered by intent and the app
orientation is different from the screen orientation, the
captured image in review will be rotated.

This is because calling setScale() clears the whole matrix and make the
previous preRotate() call meaningless. Changing to postScale() solves
the problem.

BUG=31939529
TEST=Verify that the captured image in review is not rotated

Change-Id: I6d93bac094ba9b6381e350d4007e3c65c1425e31
(cherry picked from commit 3399d3acca6a65a28784185e8164e0bb40d4ef45)

src/com/android/camera/captureintent/PictureDecoder.java

index 3f1fc9c..faea254 100644 (file)
@@ -43,11 +43,11 @@ public class PictureDecoder {
         Matrix m = new Matrix();
         // Rotate if needed.
         if (pictureOrientation != 0) {
-            m.preRotate(pictureOrientation);
+            m.setRotate(pictureOrientation);
         }
         // Flip horizontally if needed.
         if (needMirror) {
-            m.setScale(-1f, 1f);
+            m.postScale(-1f, 1f);
         }
         return Bitmap.createBitmap(
                 pictureBitmap, 0, 0, pictureBitmap.getWidth(), pictureBitmap.getHeight(), m, false);