Added function to retrieve the current camera orientation

pull/240/head
Max Maes 7 years ago
parent 819638862f
commit eafae1f3d0
  1. 4
      cameraview/src/main/java/com/otaliastudios/cameraview/CameraController.java
  2. 8
      cameraview/src/main/java/com/otaliastudios/cameraview/CameraView.java

@ -269,6 +269,10 @@ abstract class CameraController implements
mDisplayOffset = displayOffset; mDisplayOffset = displayOffset;
} }
final int getDeviceOrientation() {
return mDeviceOrientation;
}
// This can be called multiple times. // This can be called multiple times.
final void setDeviceOrientation(int deviceOrientation) { final void setDeviceOrientation(int deviceOrientation) {
mDeviceOrientation = deviceOrientation; mDeviceOrientation = deviceOrientation;

@ -1288,6 +1288,14 @@ public class CameraView extends FrameLayout {
}); });
} }
/**
* Returns the orientation of the camera.
* This is available after {@link CameraListener#onCameraOpened(CameraOptions)} has been called.
* @return Returns a value of 0, 90, 180 or 270.
*/
public int getCameraOrientation() {
return (mCameraController.getDeviceOrientation() + mOrientationHelper.getDisplayOffset()) % 360;
}
/** /**
* Returns the size used for the preview, * Returns the size used for the preview,

Loading…
Cancel
Save