开发者

1.6 to 2.1 CameraInfo alternative?

开发者 https://www.devze.com 2023-02-14 17:55 出处:网络
android.Camera.Preferences.setRotation documentation public void onOrientationChanged(int orientation) {

android.Camera.Preferences.setRotation documentation

public void onOrientationChanged(int orientation) {     
    if (orientation == ORIENTATION_UNKNOWN) return;    开发者_StackOverflow 
    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); 
}

is there an alternative to Camera.CameraInfo in API level 5 (or better yet even 4)? I am trying to set the rotation of the captured image and I cannot figure out how to get the orientation of the device's camera. pre API level 9 was all camera's orientation fixed or something?


No the camera orientation is at the current status a real mess on Android platform. Even the orientation you get with the camera info is not always the right one (at least for me) in my app i'm letting the user choose if he wants to rotate the camera with a parameter in the settings of the app

0

精彩评论

暂无评论...
验证码 换一张
取 消