0

android.Camera.Preferences.setRotation documentation1.6至2.1 CameraInfo的替代?

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;  
    }  
    mParameters.setRotation(rotation); 
} 

是有在API級別5至Camera.CameraInfo的替代方案(或更好,但甚至4)?我試圖設置捕獲的圖像的旋轉,我無法弄清楚如何獲取設備的相機的方向。預先API級別9是所有相機的方向固定或什麼?

回答

0

沒有相機方向在Android平臺上處於當前狀態。 即使您使用相機信息獲取的方向並不總是正確的(至少對我來說)在我的應用程序中,我讓用戶選擇是否要使用應用程序的設置中的參數旋轉相機

+0

查看camerainfo文檔,它不返回屏幕方向,但相機正在觀看的位置http://developer.android.com/reference/android/hardware/Camera.CameraInfo.html#orientation – Hrk 2012-10-26 09:59:15

相關問題