summaryrefslogtreecommitdiffstats
path: root/src/com/android/camera/Util.java
diff options
context:
space:
mode:
authorWu-cheng Li <wuchengli@google.com>2010-11-09 22:00:27 +0800
committerWu-cheng Li <wuchengli@google.com>2010-11-18 14:03:25 +0800
commit9cfab4bc18b8d9d905263c687e19c06df885dca7 (patch)
treea954f01a254f3e0d9334ad29d8534aca94e98ad9 /src/com/android/camera/Util.java
parent16eb20a2ee0aed297d41b82894ade3b57536d543 (diff)
downloadLegacyCamera-9cfab4bc18b8d9d905263c687e19c06df885dca7.tar.gz
LegacyCamera-9cfab4bc18b8d9d905263c687e19c06df885dca7.tar.bz2
LegacyCamera-9cfab4bc18b8d9d905263c687e19c06df885dca7.zip
Rotate the postview to correct orientation in video attach mode.
Manual merge from gingerbread. bug:3208306 Change-Id: Ib7fb0a960c862527324adefd419e74224f59bc30
Diffstat (limited to 'src/com/android/camera/Util.java')
-rw-r--r--src/com/android/camera/Util.java20
1 files changed, 19 insertions, 1 deletions
diff --git a/src/com/android/camera/Util.java b/src/com/android/camera/Util.java
index 71d0c217..ac99956c 100644
--- a/src/com/android/camera/Util.java
+++ b/src/com/android/camera/Util.java
@@ -54,10 +54,28 @@ public class Util {
// Rotates the bitmap by the specified degree.
// If a new bitmap is created, the original bitmap is recycled.
public static Bitmap rotate(Bitmap b, int degrees) {
- if (degrees != 0 && b != null) {
+ return rotateAndMirror(b, degrees, false);
+ }
+
+ // Rotates and/or mirrors the bitmap. If a new bitmap is created, the
+ // original bitmap is recycled.
+ public static Bitmap rotateAndMirror(Bitmap b, int degrees, boolean mirror) {
+ if ((degrees != 0 || mirror) && b != null) {
Matrix m = new Matrix();
m.setRotate(degrees,
(float) b.getWidth() / 2, (float) b.getHeight() / 2);
+ if (mirror) {
+ m.postScale(-1, 1);
+ degrees = (degrees + 360) % 360;
+ if (degrees == 0 || degrees == 180) {
+ m.postTranslate((float) b.getWidth(), 0);
+ } else if (degrees == 90 || degrees == 270) {
+ m.postTranslate((float) b.getHeight(), 0);
+ } else {
+ throw new IllegalArgumentException("Invalid degrees=" + degrees);
+ }
+ }
+
try {
Bitmap b2 = Bitmap.createBitmap(
b, 0, 0, b.getWidth(), b.getHeight(), m, true);