get Camera Jpeg Rotation - Android Camera

Android examples for Camera:Camera Attribute

Description

get Camera Jpeg Rotation

Demo Code


//package com.java2s;

import android.view.OrientationEventListener;

import static android.hardware.Camera.CameraInfo;

public class Main {
    public static int getJpegRotation(CameraInfo info,
            int displayOrientation) {
        // See android.hardware.Camera.Parameters.setRotation for
        // documentation.
        int rotation = 0;
        if (displayOrientation != OrientationEventListener.ORIENTATION_UNKNOWN) {
            if (info.facing == CameraInfo.CAMERA_FACING_FRONT) {
                rotation = (info.orientation - displayOrientation + 360) % 360;
            } else { // back-facing camera
                rotation = (info.orientation + displayOrientation) % 360;
            }//from   ww w . ja  v a2 s . co m
        }
        return rotation;
    }
}

Related Tutorials