80,351
社区成员
发帖
与我相关
我的任务
分享
public static void setCameraDisplayOrientation(Activity activity,
int cameraId, Camera camera) {
// See android.hardware.Camera.setCameraDisplayOrientation for
// documentation.
Camera.CameraInfo info = new Camera.CameraInfo();
Camera.getCameraInfo(cameraId, info);
int degrees = getDisplayRotation(activity);
int result;
if (info.facing == Camera.CameraInfo.CAMERA_FACING_FRONT) {
Log.e(TAG, "=yue===>setCameraDisplayOrientation FACING FRONT ");
result = (info.orientation + degrees) % 360;
result = (360 - result) % 360; // compensate the mirror
} else { // back-facing
Log.e(TAG, "====>setCameraDisplayOrientation FACING BACK ");
result = (info.orientation - degrees + 360) % 360;
}
// result=270;
Log.e(TAG, "====>setCameraDisplayOrientation: result= "+ result);
camera.setDisplayOrientation(result);
}
private void capture() {
mCaptureOnlyData = null;
// See android.hardware.Camera.Parameters.setRotation for
// documentation.
int rotation = 0;
Log.e(TAG, "====>capture mOrientation ="+mOrientation);
if (mOrientation != OrientationEventListener.ORIENTATION_UNKNOWN) {
CameraInfo info = CameraHolder.instance().getCameraInfo()[mCameraId];
Log.e(TAG, "====>capture info.orientation ="+(info.orientation));
if (info.facing == CameraInfo.CAMERA_FACING_FRONT) {
rotation = (info.orientation - mOrientation + 360) % 360;
} else { // back-facing camera
rotation = (info.orientation + mOrientation) % 360;
}
}
mParameters.setRotation(rotation);