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
public static int getScreenRotation(Activity activity) { switch (activity.getWindowManager().getDefaultDisplay().getRotation()) { default:/*from w ww. j av a2 s . c om*/ case Surface.ROTATION_0: return 0; case Surface.ROTATION_90: return 90; case Surface.ROTATION_180: return 180; case Surface.ROTATION_270: return 270; } }
From source file:Main.java
public static int getOrientation(int rotation, boolean upsideDown) { if (upsideDown) { switch (rotation) { case Surface.ROTATION_0: return 270; case Surface.ROTATION_90: return 180; case Surface.ROTATION_180: return 90; case Surface.ROTATION_270: return 0; }/* w ww . ja v a2s . c o m*/ } else { switch (rotation) { case Surface.ROTATION_0: return 90; case Surface.ROTATION_90: return 0; case Surface.ROTATION_180: return 270; case Surface.ROTATION_270: return 180; } } return 0; }
From source file:Main.java
public static int getRotationAdjustment(int screenRotation) { int degrees = 0; switch (screenRotation) { case Surface.ROTATION_0: degrees = 0;/*from w w w .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 cameraOrientation = getCameraOrientation(); return (cameraOrientation - degrees + 360) % 360; }
From source file:Main.java
public static void sensorRotation2Matrix(float[] gravity, float[] geomagnetic, int rotation, float[] output) { switch (rotation) { case Surface.ROTATION_0: case Surface.ROTATION_180: /* Notice: not supported for ROTATION_180! */ SensorManager.getRotationMatrix(output, null, gravity, geomagnetic); break;// w ww . j a v a 2s . c o m case Surface.ROTATION_90: SensorManager.getRotationMatrix(mTmp, null, gravity, geomagnetic); SensorManager.remapCoordinateSystem(mTmp, SensorManager.AXIS_Y, SensorManager.AXIS_MINUS_X, output); break; case Surface.ROTATION_270: SensorManager.getRotationMatrix(mTmp, null, gravity, geomagnetic); SensorManager.remapCoordinateSystem(mTmp, SensorManager.AXIS_MINUS_Y, SensorManager.AXIS_X, output); break; } Matrix.rotateM(output, 0, 90.0F, 1.0F, 0.0F, 0.0F); }
From source file:Main.java
/** * Returns the rotation of the screen from its "natural" orientation. * Notice: ANTICLOCKWISE//from w ww . jav a 2 s. c om * @param rotation "getRotation()" */ public static String getRotationStr(int rotation) { switch (rotation) { //Natural orientation case Surface.ROTATION_0://0 return "ROTATION_0"; case Surface.ROTATION_90://1 return "ROTATION_90"; case Surface.ROTATION_180://2 return "ROTATION_180"; case Surface.ROTATION_270://3 return "ROTATION_270"; default: return UNKNOWN; } }
From source file:Main.java
public static void sensorRotationVector2Matrix(SensorEvent event, int rotation, float[] output) { float[] values = event.values; switch (rotation) { case Surface.ROTATION_0: case Surface.ROTATION_180: /* Notice: not supported for ROTATION_180! */ SensorManager.getRotationMatrixFromVector(output, values); break;/*from ww w . jav a2 s . c o m*/ case Surface.ROTATION_90: SensorManager.getRotationMatrixFromVector(mTmp, values); SensorManager.remapCoordinateSystem(mTmp, SensorManager.AXIS_Y, SensorManager.AXIS_MINUS_X, output); break; case Surface.ROTATION_270: SensorManager.getRotationMatrixFromVector(mTmp, values); SensorManager.remapCoordinateSystem(mTmp, SensorManager.AXIS_MINUS_Y, SensorManager.AXIS_X, output); break; } Matrix.rotateM(output, 0, 90.0F, 1.0F, 0.0F, 0.0F); }
From source file:Main.java
public static int setCameraDisplayOrientation(int cameraId, Camera camera, int displayRotation) { CameraInfo info = new CameraInfo(); Camera.getCameraInfo(cameraId, info); int degrees = 0; switch (displayRotation) { case Surface.ROTATION_0: degrees = 0;// www.j a v 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 == 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 void setCameraDisplayOrientation(int rotation, int cameraId, Camera camera) { 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 www . j a v a 2s . 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 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; } camera.setDisplayOrientation(result); }
From source file:Main.java
/** * Untested, taken from stack-overflow.// ww w. j a va 2s.c o m * * @param activity */ public static void disableScreenOrientationChange(Activity activity) { final int orientation = activity.getResources().getConfiguration().orientation; final int rotation = activity.getWindowManager().getDefaultDisplay().getRotation(); if (rotation == Surface.ROTATION_0 || rotation == Surface.ROTATION_90) { if (orientation == Configuration.ORIENTATION_PORTRAIT) { activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); } else if (orientation == Configuration.ORIENTATION_LANDSCAPE) { activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); } } else if (rotation == Surface.ROTATION_180 || rotation == Surface.ROTATION_270) { if (orientation == Configuration.ORIENTATION_PORTRAIT) { activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT); } else if (orientation == Configuration.ORIENTATION_LANDSCAPE) { activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE); } } }
From source file:Main.java
public static int getOrientationHint(Activity activity, int cameraId, android.hardware.Camera camera) { android.hardware.Camera.CameraInfo info = new android.hardware.Camera.CameraInfo(); android.hardware.Camera.getCameraInfo(cameraId, info); int rotation = activity.getWindowManager().getDefaultDisplay().getRotation(); int degrees = 0; switch (rotation) { case Surface.ROTATION_0: degrees = 0;//from w ww .jav 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; } int result; if (info.facing == Camera.CameraInfo.CAMERA_FACING_FRONT) { result = (info.orientation + degrees) % 360; } else { // back-facing result = (info.orientation - degrees + 360) % 360; } return result; }