summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDoris Liu <tianliu@google.com>2013-10-25 20:20:43 -0700
committerDoris Liu <tianliu@google.com>2013-10-27 21:17:55 -0700
commitd053a5b2aa8cd9cb09bd40962b305ef34e7d404b (patch)
tree57157319c890fd05a6aa51cbc1d2c91fdc908264 /src
parent5737b93254f451859c7924792c46354d385da946 (diff)
downloadandroid_packages_apps_Snap-d053a5b2aa8cd9cb09bd40962b305ef34e7d404b.tar.gz
android_packages_apps_Snap-d053a5b2aa8cd9cb09bd40962b305ef34e7d404b.tar.bz2
android_packages_apps_Snap-d053a5b2aa8cd9cb09bd40962b305ef34e7d404b.zip
Update aspect ratio when preview aspect ratio changes
Bug: 11250125 Change-Id: If4047860f056cd81bf7d74045a68f5c0b85ad067
Diffstat (limited to 'src')
-rw-r--r--src/com/android/camera/PhotoModule.java4
-rw-r--r--src/com/android/camera/PhotoUI.java18
2 files changed, 22 insertions, 0 deletions
diff --git a/src/com/android/camera/PhotoModule.java b/src/com/android/camera/PhotoModule.java
index aeca3ddef..6cb5e55e6 100644
--- a/src/com/android/camera/PhotoModule.java
+++ b/src/com/android/camera/PhotoModule.java
@@ -1600,6 +1600,10 @@ public class PhotoModule
Size original = mParameters.getPreviewSize();
if (!original.equals(optimalSize)) {
mParameters.setPreviewSize(optimalSize.width, optimalSize.height);
+ if(optimalSize.width != 0 && optimalSize.height != 0) {
+ mUI.updatePreviewAspectRatio((float) optimalSize.width
+ / (float) optimalSize.height);
+ }
// Zoom related settings will be changed for different preview
// sizes, so set and read the parameters to get latest values
diff --git a/src/com/android/camera/PhotoUI.java b/src/com/android/camera/PhotoUI.java
index cd3b9a52f..452b7e05f 100644
--- a/src/com/android/camera/PhotoUI.java
+++ b/src/com/android/camera/PhotoUI.java
@@ -224,6 +224,24 @@ public class PhotoUI implements PieListener,
mSurfaceTextureSizeListener = listener;
}
+ public void updatePreviewAspectRatio(float aspectRatio) {
+ if (aspectRatio <= 0) {
+ Log.e(TAG, "Invalid aspect ratio: " + aspectRatio);
+ return;
+ }
+ if (aspectRatio < 1f) {
+ aspectRatio = 1f / aspectRatio;
+ }
+
+ if (mAspectRatio != aspectRatio) {
+ mAspectRatio = aspectRatio;
+ // Update transform matrix with the new aspect ratio.
+ if (mPreviewWidth != 0 && mPreviewHeight != 0) {
+ setTransformMatrix(mPreviewWidth, mPreviewHeight);
+ }
+ }
+ }
+
private void setTransformMatrix(int width, int height) {
mMatrix = mTextureView.getTransform(mMatrix);
float scaleX = 1f, scaleY = 1f;