2

カメラのプレビューで作業しようとしています..

マニフェスト ファイルで、アクティビティの screenOrientation を横向きに設定しました。また、android:minSdkVersion は 10 に設定されています。テスト用に Android バージョン 4.0.4 で Motorola xoom を使用しています。

アクティビティ コードでは、 activity.getWindowManager().getDefaultDisplay().getRotation(); に対して「0」を取得していることがわかります。

また、info.orientation は 0 を返しています。[info は Camera.CameraInfo です。]

ただし、カメラのプレビューが横向きモードで起動されるかどうかはまだわかりません。カメラのプレビューがどのモードで起動されるかをクロス検証する方法/同じ設定方法。

4

1 に答える 1

0
public void onOrientationChanged(int orientation) {
     if (orientation == ORIENTATION_UNKNOWN) return;
     android.hardware.Camera.CameraInfo info =
            new android.hardware.Camera.CameraInfo();
     android.hardware.Camera.getCameraInfo(cameraId, info);
     orientation = (orientation + 45) / 90 * 90;
     int rotation = 0;
     if (info.facing == CameraInfo.CAMERA_FACING_FRONT) {
         rotation = (info.orientation - orientation + 360) % 360;
     } else {  // back-facing camera
         rotation = (info.orientation + orientation) % 360;
     }

Camera.Parameters の上記のメソッドを使用して、向きを知ることができます。このリンクを参照してください

于 2012-05-20T03:16:28.640 に答える