List of usage examples for android.view Surface ROTATION_90
int ROTATION_90
To view the source code for android.view Surface ROTATION_90.
Click Source Link
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 w w w . java 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; result = (360 - result) % 360; // compensate the mirror } else { // back-facing result = (info.orientation - degrees + 360) % 360; } camera.setDisplayOrientation(result); }
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;/* w ww . j a 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; } else { // back-facing result = (info.orientation - degrees + 360) % 360; } return result; }
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;/*w w w .j ava 2s.c om*/ 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(Activity activity, 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 va2 s . 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 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; } Log.d(TAG, "camera display orientation: " + result); camera.setDisplayOrientation(result); return result; }
From source file:Main.java
/** * Determine the rotation to apply for the preview for a given camera * @param mirror whether to account for profile camera mirroring or not *//* ww w .ja v a 2 s .c o m*/ public static int getRotationDegrees(Activity activity, int cameraId, boolean mirror) { int rotation = activity.getWindowManager().getDefaultDisplay().getRotation(); int degrees = 0; switch (rotation) { case Surface.ROTATION_0: degrees = 0; break; case Surface.ROTATION_90: degrees = 90; break; case Surface.ROTATION_180: degrees = 180; break; case Surface.ROTATION_270: degrees = 270; break; } android.hardware.Camera.CameraInfo info = new android.hardware.Camera.CameraInfo(); android.hardware.Camera.getCameraInfo(cameraId, info); if (info.facing == Camera.CameraInfo.CAMERA_FACING_FRONT) { degrees = (info.orientation + degrees) % 360; // compensate for mirrored image, useful for previews on front facing cameras if (mirror) { degrees = (360 - degrees) % 360; } } else { degrees = (info.orientation - degrees + 360) % 360; } return degrees; }
From source file:Main.java
public static void setCameraDisplayOrientation(Context mContext, int cameraId, Camera camera) { CameraInfo info = new CameraInfo(); Camera.getCameraInfo(cameraId, info); int rotation = ((Activity) mContext).getWindowManager().getDefaultDisplay().getRotation(); int degrees = 0; switch (rotation) { case Surface.ROTATION_0: degrees = 0;/*w w w .j a va2 s.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 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
public static void setCameraDisplayOrientation(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 w w . ja 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 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
public static int getCameraDisplayOrientation(@NonNull Activity activity, @NonNull CameraInfo info) { int rotation = activity.getWindowManager().getDefaultDisplay().getRotation(); int degrees = 0; DisplayMetrics dm = new DisplayMetrics(); activity.getWindowManager().getDefaultDisplay().getMetrics(dm); switch (rotation) { case Surface.ROTATION_0: degrees = 0;/*from w w w. j av a 2 s . c om*/ break; case Surface.ROTATION_90: degrees = 90; break; case Surface.ROTATION_180: degrees = 180; break; case Surface.ROTATION_270: degrees = 270; break; } if (info.facing == Camera.CameraInfo.CAMERA_FACING_FRONT) { return (360 - ((info.orientation + degrees) % 360)) % 360; } else { return (info.orientation - degrees + 360) % 360; } }
From source file:Main.java
public static int convertRotationToTiOrientationMode(int rotation) { switch (rotation) { case Surface.ROTATION_0: return ORIENTATION_PORTRAIT; case Surface.ROTATION_90: return ORIENTATION_LANDSCAPE; case Surface.ROTATION_180: return ORIENTATION_PORTRAIT_REVERSE; case Surface.ROTATION_270: return ORIENTATION_LANDSCAPE_REVERSE; default:/*from ww w .j a va 2 s . c om*/ return ORIENTATION_UNKNOWN; } }
From source file:Main.java
private static int getCameraDisplayOrientation_1(Activity activity, @SuppressWarnings("deprecation") Camera.CameraInfo cameraInfo) { // 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 w w .j a va2s .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; default: { Log.e(TAG, "un deal with handler task"); } break; } int result; //noinspection deprecation if (cameraInfo.facing == Camera.CameraInfo.CAMERA_FACING_FRONT) { result = (cameraInfo.orientation + degrees) % 360; result = (360 - result) % 360; // compensate the mirror } else { // back-facing result = (cameraInfo.orientation - degrees + 360) % 360; } return result; }