List of usage examples for android.view Surface ROTATION_0
int ROTATION_0
To view the source code for android.view Surface ROTATION_0.
Click Source Link
From source file:Main.java
static int calculateOrientation(Activity activity, int cameraId) { if (cameraId == NO_CAMERA) return 0; DisplayMetrics dm = new DisplayMetrics(); Camera.CameraInfo info = new Camera.CameraInfo(); Camera.getCameraInfo(cameraId, info); int cameraRotationOffset = info.orientation; activity.getWindowManager().getDefaultDisplay().getMetrics(dm); int currentScreenRotation = activity.getWindowManager().getDefaultDisplay().getRotation(); int degrees = 0; switch (currentScreenRotation) { case Surface.ROTATION_0: degrees = 0;/* w w w .j a v a 2s . c om*/ break; case Surface.ROTATION_90: degrees = 90; break; case Surface.ROTATION_180: degrees = 180; break; case Surface.ROTATION_270: degrees = 270; break; } int orientation; if (info.facing == Camera.CameraInfo.CAMERA_FACING_FRONT) { orientation = (cameraRotationOffset + degrees) % 360; orientation = (360 - orientation) % 360; } else { orientation = (cameraRotationOffset - degrees + 360) % 360; } return orientation; }
From source file:Main.java
public static int getDisplayRotation(Activity activity) { int rotation = activity.getWindowManager().getDefaultDisplay().getRotation(); switch (rotation) { case Surface.ROTATION_0: return 0; case Surface.ROTATION_90: return 90; case Surface.ROTATION_180: return 180; case Surface.ROTATION_270: return 270; }/*w ww. j a va 2s .com*/ return 0; }
From source file:Main.java
private static int getDeviceOrientationDegree(Context context) { int degrees = 0; WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); int rotation = windowManager.getDefaultDisplay().getRotation(); switch (rotation) { case Surface.ROTATION_0: degrees = 0;//from w w w . j a va2 s.co m break; case Surface.ROTATION_90: degrees = 90; break; case Surface.ROTATION_180: degrees = 180; break; case Surface.ROTATION_270: degrees = 270; break; } return degrees; }
From source file:Main.java
public static int getOrientationInDegree(Activity activity) { int rotation = activity.getWindowManager().getDefaultDisplay().getRotation(); int degrees = 0; switch (rotation) { case Surface.ROTATION_0: degrees = 0;/*w w w.j av a 2s .co m*/ break; case Surface.ROTATION_90: degrees = 90; break; case Surface.ROTATION_180: degrees = 180; break; case Surface.ROTATION_270: degrees = 270; break; } return degrees; }
From source file:Main.java
public static int setCameraDisplayOrientation(int cameraId, android.hardware.Camera camera, int displayRotation) { Camera.CameraInfo info = new Camera.CameraInfo(); Camera.getCameraInfo(cameraId, info); int degrees = 0; switch (displayRotation) { case Surface.ROTATION_0: degrees = 0;// w ww .j av a 2 s. c o m break; case Surface.ROTATION_90: degrees = 90; break; case Surface.ROTATION_180: degrees = 180; break; case Surface.ROTATION_270: degrees = 270; break; } int camRotationDegree = 0; if (info.facing == Camera.CameraInfo.CAMERA_FACING_FRONT) { camRotationDegree = (info.orientation + degrees) % 360; camRotationDegree = (360 - camRotationDegree) % 360; // compensate the mirror } else { camRotationDegree = (info.orientation - degrees + 360) % 360; } if (camera != null) { camera.setDisplayOrientation(camRotationDegree); } return camRotationDegree; }
From source file:Main.java
public static int setCameraDisplayOrientation(int cameraId, android.hardware.Camera camera, int displayRotation) { Camera.CameraInfo info = new Camera.CameraInfo(); Camera.getCameraInfo(cameraId, info); int degrees = 0; switch (displayRotation) { case Surface.ROTATION_0: degrees = 0;//www.j a v a2 s. c o m break; case Surface.ROTATION_90: degrees = 90; break; case Surface.ROTATION_180: degrees = 180; break; case Surface.ROTATION_270: degrees = 270; break; } int camRotationDegree = 0; if (info.facing == Camera.CameraInfo.CAMERA_FACING_FRONT) { camRotationDegree = (info.orientation + degrees) % 360; camRotationDegree = (360 - camRotationDegree) % 360; // compensate the mirror } else { camRotationDegree = (info.orientation - degrees + 360) % 360; } if (camera != null) { try { camera.setDisplayOrientation(camRotationDegree); } catch (RuntimeException e) { // java.lang.RuntimeException: set display orientation failed e.printStackTrace(); } } return camRotationDegree; }
From source file:Main.java
public static int getOrientationHint(Activity activity, int cameraId) { Camera.CameraInfo info = new Camera.CameraInfo(); Camera.getCameraInfo(cameraId, info); int rotation = activity.getWindowManager().getDefaultDisplay().getRotation(); int degrees = 0; switch (rotation) { case Surface.ROTATION_0: degrees = 0;// w w w . j a v a 2s . co m break; case Surface.ROTATION_90: degrees = 90; break; case Surface.ROTATION_180: degrees = 180; break; case Surface.ROTATION_270: degrees = 270; break; } int result = 0; if (info.facing == Camera.CameraInfo.CAMERA_FACING_FRONT) { result = (info.orientation - degrees + 360) % 360; } else { // back-facing camera result = (info.orientation + degrees) % 360; } return result; }
From source file:Main.java
public static int getCameraDisplayOrientation(Activity activity, int cameraId) { Camera.CameraInfo info = new Camera.CameraInfo(); Camera.getCameraInfo(cameraId, info); int rotation = activity.getWindowManager().getDefaultDisplay().getRotation(); int degrees = 0; switch (rotation) { case Surface.ROTATION_0: degrees = 0;/*from w ww . ja v a 2 s . co m*/ break; case Surface.ROTATION_90: degrees = 90; break; case Surface.ROTATION_180: degrees = 180; break; case Surface.ROTATION_270: degrees = 270; break; } int result; if (info.facing == Camera.CameraInfo.CAMERA_FACING_FRONT) { result = (info.orientation + degrees) % 360; result = (360 - result) % 360; // compensate the mirror } else { // back-facing result = (info.orientation - degrees + 360) % 360; } return result; }
From source file:Main.java
static int calculateOrientation(Activity activity, int cameraId) { if (cameraId == NO_CAMERA) return 0; DisplayMetrics dm = new DisplayMetrics(); Camera.CameraInfo info = new Camera.CameraInfo(); Camera.getCameraInfo(cameraId, info); int cameraRotationOffset = info.orientation; Log.w(TAG, "cameraRotationOffset = " + cameraRotationOffset); activity.getWindowManager().getDefaultDisplay().getMetrics(dm); int currentScreenRotation = activity.getWindowManager().getDefaultDisplay().getRotation(); Log.w(TAG, "currentScreenRotation = " + currentScreenRotation); int degrees = 0; switch (currentScreenRotation) { case Surface.ROTATION_0: degrees = 0;//from w w w .ja va2s . com break; case Surface.ROTATION_90: degrees = 90; break; case Surface.ROTATION_180: degrees = 180; break; case Surface.ROTATION_270: degrees = 270; break; } Log.w(TAG, "degrees = " + degrees); int orientation; if (info.facing == Camera.CameraInfo.CAMERA_FACING_FRONT) { orientation = (cameraRotationOffset + degrees) % 360; orientation = (360 - orientation) % 360; } else { orientation = (cameraRotationOffset - degrees + 360) % 360; } Log.w(TAG, "orientation = " + orientation); return orientation; }
From source file:Main.java
static int calculateOrientationHint(Activity activity, int cameraId) { if (cameraId == NO_CAMERA) return 0; DisplayMetrics dm = new DisplayMetrics(); Camera.CameraInfo info = new Camera.CameraInfo(); Camera.getCameraInfo(cameraId, info); int cameraRotationOffset = info.orientation; Log.w(TAG, "OrientationHint cameraRotationOffset = " + cameraRotationOffset); activity.getWindowManager().getDefaultDisplay().getMetrics(dm); int currentScreenRotation = activity.getWindowManager().getDefaultDisplay().getRotation(); Log.w(TAG, "OrientationHint currentScreenRotation = " + currentScreenRotation); int degrees = 0; switch (currentScreenRotation) { case Surface.ROTATION_0: degrees = 0;/*from w ww . j a v a 2 s .com*/ break; case Surface.ROTATION_90: degrees = 90; break; case Surface.ROTATION_180: degrees = 180; break; case Surface.ROTATION_270: degrees = 270; break; } Log.w(TAG, "OrientationHint degrees = " + degrees); int orientation; if (info.facing == Camera.CameraInfo.CAMERA_FACING_FRONT) { orientation = (cameraRotationOffset + degrees) % 360; if (degrees != 0) { orientation = (360 - orientation) % 360; } } else { orientation = (cameraRotationOffset - degrees + 360) % 360; } Log.w(TAG, "orientationHint = " + orientation); return orientation; }