summaryrefslogtreecommitdiffstats
path: root/src/com/android/camera/VideoUI.java
diff options
context:
space:
mode:
authorSanthosh Kumar H E <skhara@codeaurora.org>2013-10-25 13:14:10 +0530
committerLinux Build Service Account <lnxbuild@localhost>2013-10-31 19:40:12 -0600
commit6bc53a127961ec9006c8305a576091c69dce641d (patch)
tree202070705a2084f50a8d465364df8ffa59856e94 /src/com/android/camera/VideoUI.java
parenta051ea5f2d2568144ba1c491153877d55076343d (diff)
downloadandroid_packages_apps_Snap-6bc53a127961ec9006c8305a576091c69dce641d.tar.gz
android_packages_apps_Snap-6bc53a127961ec9006c8305a576091c69dce641d.tar.bz2
android_packages_apps_Snap-6bc53a127961ec9006c8305a576091c69dce641d.zip
Camera: Fix for stretched preview in camera and camcorder...
Stretched preview is observed in front camera due to sensor's mount angle. So resizing the preview by considering aspect ratio of the preview. (cherry picked from commit Ie8a9e062782aa6caaa80ddab705c937da6b0761e) Change-Id: I0bca9076a6dffa4c4972e6d5d0939c57569615bd Conflicts: src/com/android/camera/PhotoMenu.java src/com/android/camera/PhotoModule.java Conflicts: src/com/android/camera/PhotoMenu.java src/com/android/camera/PhotoModule.java (cherry picked from commit 2960ef94825458dc07a497d4414155b57ae620d7) (cherry picked from commit d2fbed622a486151a656261d0dd56c896f0cc700)
Diffstat (limited to 'src/com/android/camera/VideoUI.java')
-rw-r--r--src/com/android/camera/VideoUI.java71
1 files changed, 58 insertions, 13 deletions
diff --git a/src/com/android/camera/VideoUI.java b/src/com/android/camera/VideoUI.java
index be325c459..f6027a375 100644
--- a/src/com/android/camera/VideoUI.java
+++ b/src/com/android/camera/VideoUI.java
@@ -16,6 +16,7 @@
package com.android.camera;
+import android.content.res.Configuration;
import android.graphics.Bitmap;
import android.graphics.Color;
import android.graphics.Matrix;
@@ -92,6 +93,8 @@ public class VideoUI implements PieRenderer.PieListener,
private List<Integer> mZoomRatios;
private View mPreviewThumb;
private View mFlashOverlay;
+ private boolean mOrientationResize;
+ private boolean mPrevOrientationResize;
private SurfaceView mSurfaceView = null;
private int mPreviewWidth = 0;
@@ -99,6 +102,7 @@ public class VideoUI implements PieRenderer.PieListener,
private float mSurfaceTextureUncroppedWidth;
private float mSurfaceTextureUncroppedHeight;
private float mAspectRatio = 4f / 3f;
+ private boolean mAspectRatioResize;
private Matrix mMatrix = null;
private final AnimationManager mAnimationManager;
private final Handler mHandler = new Handler() {
@@ -126,10 +130,13 @@ public class VideoUI implements PieRenderer.PieListener,
w = height;
h = width;
}
- if (mPreviewWidth != width || mPreviewHeight != height) {
+ if (mPreviewWidth != width || mPreviewHeight != height
+ || (mOrientationResize != mPrevOrientationResize)
+ || (mAspectRatioResize)) {
mPreviewWidth = width;
mPreviewHeight = height;
onScreenSizeChanged(width, height, w, h);
+ mAspectRatioResize = false;
}
}
};
@@ -180,8 +187,14 @@ public class VideoUI implements PieRenderer.PieListener,
initializeControlByIntent();
initializeOverlay();
mAnimationManager = new AnimationManager();
+ mOrientationResize = false;
+ mPrevOrientationResize = false;
}
+ public void cameraOrientationPreviewResize(boolean orientation){
+ mPrevOrientationResize = mOrientationResize;
+ mOrientationResize = orientation;
+ }
public void initializeSurfaceView() {
mSurfaceView = new SurfaceView(mActivity);
@@ -241,10 +254,21 @@ public class VideoUI implements PieRenderer.PieListener,
Log.w(TAG, "Preview size should not be 0.");
return;
}
+ float ratio;
if (width > height) {
- mAspectRatio = (float) width / height;
+ ratio = (float) width / height;
} else {
- mAspectRatio = (float) height / width;
+ ratio = (float) height / width;
+ }
+ if (mOrientationResize &&
+ mActivity.getResources().getConfiguration().orientation
+ != Configuration.ORIENTATION_PORTRAIT) {
+ ratio = 1 / ratio;
+ }
+
+ if (ratio != mAspectRatio){
+ mAspectRatioResize = true;
+ mAspectRatio = ratio;
}
mHandler.sendEmptyMessage(UPDATE_TRANSFORM_MATRIX);
}
@@ -266,16 +290,26 @@ public class VideoUI implements PieRenderer.PieListener,
int orientation = CameraUtil.getDisplayRotation(mActivity);
float scaleX = 1f, scaleY = 1f;
float scaledTextureWidth, scaledTextureHeight;
- if (width > height) {
- scaledTextureWidth = Math.max(width,
- (int) (height * mAspectRatio));
- scaledTextureHeight = Math.max(height,
- (int)(width / mAspectRatio));
+ if (mOrientationResize){
+ if (width/mAspectRatio > height){
+ scaledTextureHeight = height;
+ scaledTextureWidth = (int)(height * mAspectRatio + 0.5f);
+ } else {
+ scaledTextureWidth = width;
+ scaledTextureHeight = (int)(width / mAspectRatio + 0.5f);
+ }
} else {
- scaledTextureWidth = Math.max(width,
- (int) (height / mAspectRatio));
- scaledTextureHeight = Math.max(height,
- (int) (width * mAspectRatio));
+ if (width > height) {
+ scaledTextureWidth = Math.max(width,
+ (int) (height * mAspectRatio));
+ scaledTextureHeight = Math.max(height,
+ (int)(width / mAspectRatio));
+ } else {
+ scaledTextureWidth = Math.max(width,
+ (int) (height / mAspectRatio));
+ scaledTextureHeight = Math.max(height,
+ (int) (width * mAspectRatio));
+ }
}
if (mSurfaceTextureUncroppedWidth != scaledTextureWidth ||
@@ -483,7 +517,18 @@ public class VideoUI implements PieRenderer.PieListener,
}
public void setAspectRatio(double ratio) {
- // mPreviewFrameLayout.setAspectRatio(ratio);
+ if (mOrientationResize &&
+ mActivity.getResources().getConfiguration().orientation
+ != Configuration.ORIENTATION_PORTRAIT) {
+ ratio = 1 / ratio;
+ }
+
+ if (ratio != mAspectRatio){
+ mAspectRatioResize = true;
+ mAspectRatio = (float)ratio;
+ }
+ mHandler.sendEmptyMessage(UPDATE_TRANSFORM_MATRIX);
+
}
public void showTimeLapseUI(boolean enable) {