diff options
author | Chih-Chung Chang <chihchung@google.com> | 2010-06-14 04:11:00 -0700 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2010-06-14 04:11:00 -0700 |
commit | f1cefa916712dafc8b47f6eb8132a688892d4995 (patch) | |
tree | a61fbb42a5c8e4871ccbfa6c548ea67b1d71e1b7 | |
parent | 28a6c8e9b366ecfc3518e6b0fb1d1bc46cf823e8 (diff) | |
parent | 724c52244423feced2677fbd1f905e0b8b0639f2 (diff) | |
download | frameworks_base-f1cefa916712dafc8b47f6eb8132a688892d4995.zip frameworks_base-f1cefa916712dafc8b47f6eb8132a688892d4995.tar.gz frameworks_base-f1cefa916712dafc8b47f6eb8132a688892d4995.tar.bz2 |
am 724c5224: Correct the setDisplayOrientation sample code.
Merge commit '724c52244423feced2677fbd1f905e0b8b0639f2' into gingerbread
* commit '724c52244423feced2677fbd1f905e0b8b0639f2':
Correct the setDisplayOrientation sample code.
-rw-r--r-- | core/java/android/hardware/Camera.java | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/core/java/android/hardware/Camera.java b/core/java/android/hardware/Camera.java index 7640cc1..64380c5 100644 --- a/core/java/android/hardware/Camera.java +++ b/core/java/android/hardware/Camera.java @@ -624,16 +624,26 @@ public class Camera { * be called during preview. * * If you want to make the camera image show in the same orientation as - * the display, you can use <p> + * the display, you can use the following code.<p> * <pre> - * android.view.Display display; - * android.hardware.Camera.CameraInfo cameraInfo; + * public static void setCameraDisplayOrientation(Activity activity, + * int cameraId, android.hardware.Camera camera) { + * android.hardware.Camera.CameraInfo info = + * new android.hardware.Camera.CameraInfo(); + * android.hardware.Camera.getCameraInfo(cameraId, info); + * int rotation = activity.getWindowManager().getDefaultDisplay() + * .getRotation(); + * int degrees = 0; + * switch (rotation) { + * case Surface.ROTATION_0: degrees = 0; break; + * case Surface.ROTATION_90: degrees = 90; break; + * case Surface.ROTATION_180: degrees = 180; break; + * case Surface.ROTATION_270: degrees = 270; break; + * } * - * int rotation = getWindowManager().getDefaultDisplay().getRotation(); - * android.hardware.Camera.getCameraInfo(id, cameraInfo); - * int degrees = (cameraInfo.mOrientation - rotation + 360) % 360; - * - * setDisplayOrientation(degrees); + * int result = (info.mOrientation - degrees + 360) % 360; + * camera.setDisplayOrientation(result); + * } * </pre> * @param degrees the angle that the picture will be rotated clockwise. * Valid values are 0, 90, 180, and 270. The starting |