2

携帯電話を「縦向きモード」で持っていますが、cameraPreview横向きモードになっています (つまり、何かが 90 度回転しているのが見えます)。電話を「横向きモード」で保持するように回転させたとき、プレビューは問題なく「横向きモード」にあり、画像は回転しません。へのアクセス権がないため、ここでCamera.setDisplayOrientation(int)説明する方法は使用できません。

私はもう試した:

Camera.Parameters p = camera.getParameters();
    if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT)
    {   
        p.set("orientation", "portrait");
        p.set("rotation",90);
    }
    if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE)
    {                               
        p.set("orientation", "landscape");          
        p.set("rotation", 90);
    }
4

3 に答える 3

0

わかりましたので、問題を解決しました「surfaceCreated」メソッドで

    Method rotateMethod;
    rotateMethod = android.hardware.Camera.class.getMethod("setDisplayOrientation", int.class);
    rotateMethod.invoke(camera, 90);

すぐ後

camera = Camera.open();

(cf:キーボードが開いていないとカメラがおかしい)

于 2013-02-11T15:20:20.430 に答える
0

以下を使用して、カメラのディスプレイの向きを設定してみてください。

Camera camera;
...
camera.setDisplayOrientation(90);

surfaceCreated(SurfaceHolder holder) メソッドに入れます。私が同様の問題を抱えていたとき、これは私にとってはうまくいきました。

于 2013-02-11T14:34:08.097 に答える
0

ワークスペース プロジェクトの AndroidManifest.xml アクティビティにコードを追加します。

<application
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
    <activity
        android:name=".MainActivity"
        android:label="@string/app_name"
        android:screenOrientation="landscape"
        android:theme="@android:style/Theme.NoTitleBar" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
</application>
于 2013-02-11T15:37:05.617 に答える