当前位置: 首页>>代码示例>>Java>>正文


Java Surface.ROTATION_0属性代码示例

本文整理汇总了Java中android.view.Surface.ROTATION_0属性的典型用法代码示例。如果您正苦于以下问题:Java Surface.ROTATION_0属性的具体用法?Java Surface.ROTATION_0怎么用?Java Surface.ROTATION_0使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在android.view.Surface的用法示例。


在下文中一共展示了Surface.ROTATION_0属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getPreviewDegree

public static int getPreviewDegree(Activity activity) {
    // 获得手机的方向
    int rotation = activity.getWindowManager().getDefaultDisplay()
            .getRotation();
    int degree = 0;
    // 根据手机的方向计算相机预览画面应该选择的角度
    switch (rotation) {
        case Surface.ROTATION_0:
            degree = 90;
            break;
        case Surface.ROTATION_90:
            degree = 0;
            break;
        case Surface.ROTATION_180:
            degree = 270;
            break;
        case Surface.ROTATION_270:
            degree = 180;
            break;
    }
    return degree;
}
 
开发者ID:Liuzhiyang94,项目名称:ComponentProjectDemo,代码行数:22,代码来源:CameraActivity.java

示例2: getPortraitCameraDisplayOrientation

public static int getPortraitCameraDisplayOrientation(Context context, int cameraId, boolean isFrontCamera) {
    if (cameraId < 0 || cameraId > getCameraNumber()) {
        return -1;
    }
    Camera.CameraInfo cameraInfo = new Camera.CameraInfo();
    Camera.getCameraInfo(cameraId, cameraInfo);

    int rotation = ((WindowManager)context.getSystemService(Context.WINDOW_SERVICE)).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;
    }

    int result;
    if (isFrontCamera) {
        result = (cameraInfo.orientation + degrees) % 360;
        result = (360 - result) % 360;
    } else {
        result = (cameraInfo.orientation - degrees + 360) % 360;
    }
    return result;
}
 
开发者ID:PacktPublishing,项目名称:Expert-Android-Programming,代码行数:25,代码来源:CameraUtil.java

示例3: getScreenRotationOnPhone

/**
 * 获取当前屏幕旋转角度
 *
 * @param context
 * @return 0表示是竖屏; 90表示是左横屏; 180表示是反向竖屏; 270表示是右横屏
 */
public static int getScreenRotationOnPhone(Context context) {
    final Display display = ((WindowManager) context
            .getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();

    switch (display.getRotation()) {
        case Surface.ROTATION_0:
            return 0;

        case Surface.ROTATION_90:
            return 90;

        case Surface.ROTATION_180:
            return 180;

        case Surface.ROTATION_270:
            return -90;
    }
    return 0;
}
 
开发者ID:InnoFang,项目名称:FamilyBond,代码行数:25,代码来源:SensorEventHelper.java

示例4: getRotationAngle

public static int getRotationAngle(Activity activity)
{
	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;
	default:
		break;
	}
	return degrees;
}
 
开发者ID:feigxj,项目名称:VideoRecorder-master,代码行数:26,代码来源:Util.java

示例5: getCurrentOrientation

private int getCurrentOrientation() {
	int rotation = getWindowManager().getDefaultDisplay().getRotation();
	if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
		switch (rotation) {
		case Surface.ROTATION_0:
		case Surface.ROTATION_90:
			return ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE;
		default:
			return ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE;
		}
	} else {
		switch (rotation) {
		case Surface.ROTATION_0:
		case Surface.ROTATION_270:
			return ActivityInfo.SCREEN_ORIENTATION_PORTRAIT;
		default:
			return ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT;
		}
	}
}
 
开发者ID:amap-demo,项目名称:weex-3d-map,代码行数:20,代码来源:CaptureActivity.java

示例6: getDeviceOrientation

private int getDeviceOrientation() {
  int orientation = 0;

  WindowManager wm = (WindowManager) applicationContext.getSystemService(Context.WINDOW_SERVICE);
  switch (wm.getDefaultDisplay().getRotation()) {
    case Surface.ROTATION_90:
      orientation = 90;
      break;
    case Surface.ROTATION_180:
      orientation = 180;
      break;
    case Surface.ROTATION_270:
      orientation = 270;
      break;
    case Surface.ROTATION_0:
    default:
      orientation = 0;
      break;
  }
  return orientation;
}
 
开发者ID:Piasy,项目名称:VideoCRE,代码行数:21,代码来源:Camera1Session.java

示例7: getDisplayOrientation

private int getDisplayOrientation() {
    Camera.CameraInfo info = new Camera.CameraInfo();
    Camera.getCameraInfo(Camera.CameraInfo.CAMERA_FACING_BACK, info);
    WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    Display display = wm.getDefaultDisplay();

    int rotation = display.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;
    }

    int result;
    if (info.facing == Camera.CameraInfo.CAMERA_FACING_FRONT) {
        result = (info.orientation + degrees) % 360;
        result = (360 - result) % 360;
    } else {
        result = (info.orientation - degrees + 360) % 360;
    }
    return result;
}
 
开发者ID:yiwent,项目名称:Mobike,代码行数:32,代码来源:CameraConfigurationManager.java

示例8: onSensorChanged

@Override
public void onSensorChanged(SensorEvent event) {
    float x = event.values[0];
    float y = event.values[1];

    if (x<5 && x>-5 && y > 5)
        mOrientation = Surface.ROTATION_0; // portrait
    else if (x<-5 && y<5 && y>-5)
        mOrientation = Surface.ROTATION_270; // right
    else if (x<5 && x>-5 && y<-5)
        mOrientation = Surface.ROTATION_180; // upside down
    else if (x>5 && y<5 && y>-5)
        mOrientation = Surface.ROTATION_90; // left

    if (mListener != null) {
        mListener.orientationEvent();
    }
}
 
开发者ID:jonathan68,项目名称:react-native-camera,代码行数:18,代码来源:RCTSensorOrientationChecker.java

示例9: addChildAt

/**
 * We need to set the styleWidth and styleHeight of the one child (represented by the <View/>
 * within the <RCTModalHostView/> in Modal.js.  This needs to fill the entire window.
 */
@Override
@TargetApi(16)
public void addChildAt(ReactShadowNode child, int i) {
  super.addChildAt(child, i);

  Context context = getThemedContext();
  WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
  Display display = wm.getDefaultDisplay();
  // getCurrentSizeRange will return the min and max width and height that the window can be
  display.getCurrentSizeRange(mMinPoint, mMaxPoint);

  int width, height;
  int rotation = display.getRotation();
  if (rotation == Surface.ROTATION_0 || rotation == Surface.ROTATION_180) {
    // If we are vertical the width value comes from min width and height comes from max height
    width = mMinPoint.x;
    height = mMaxPoint.y;
  } else {
    // If we are horizontal the width value comes from max width and height comes from min height
    width = mMaxPoint.x;
    height = mMinPoint.y;
  }
  child.setStyleWidth(width);
  child.setStyleHeight(height);
}
 
开发者ID:qq565999484,项目名称:RNLearn_Project1,代码行数:29,代码来源:FlatReactModalShadowNode.java

示例10: getCurrentOrientation

private int getCurrentOrientation() {
    int rotation = getWindowManager().getDefaultDisplay().getRotation();
    switch (rotation) {
        case Surface.ROTATION_0:
        case Surface.ROTATION_90:
            return ActivityInfo.SCREEN_ORIENTATION_PORTRAIT;
        default:
            return ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT;
    }
}
 
开发者ID:yun2win,项目名称:tvConnect_android,代码行数:10,代码来源:CaptureActivity.java

示例11: getDeviceDefaultOrientation

public static int getDeviceDefaultOrientation(Context context) {
    WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    Configuration config = context.getResources().getConfiguration();

    int rotation = windowManager.getDefaultDisplay().getRotation();

    if (((rotation == Surface.ROTATION_0 || rotation == Surface.ROTATION_180) &&
            config.orientation == Configuration.ORIENTATION_LANDSCAPE)
            || ((rotation == Surface.ROTATION_90 || rotation == Surface.ROTATION_270) &&
            config.orientation == Configuration.ORIENTATION_PORTRAIT)) {
        return Configuration.ORIENTATION_LANDSCAPE;
    } else {
        return Configuration.ORIENTATION_PORTRAIT;
    }
}
 
开发者ID:MartinRGB,项目名称:android_camera_experiment,代码行数:15,代码来源:Utils.java

示例12: requestScreenCapture

@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
public boolean requestScreenCapture() {
    if (mDisplay.getRotation() == Surface.ROTATION_0 || mDisplay.getRotation() == Surface.ROTATION_180)
        return requestScreenCapture(ScreenMetrics.getDeviceScreenWidth(), ScreenMetrics.getDeviceScreenHeight());
    else
        return requestScreenCapture(ScreenMetrics.getDeviceScreenHeight(), ScreenMetrics.getDeviceScreenWidth());
}
 
开发者ID:feifadaima,项目名称:https-github.com-hyb1996-NoRootScriptDroid,代码行数:7,代码来源:Images.java

示例13: getScreenRotation

/**
 * 获取屏幕旋转角度
 *
 * @param activity activity
 * @return 屏幕旋转角度
 */
public static int getScreenRotation(Activity activity) {
    switch (activity.getWindowManager().getDefaultDisplay().getRotation()) {
        default:
        case Surface.ROTATION_0:
            return 0;
        case Surface.ROTATION_90:
            return 90;
        case Surface.ROTATION_180:
            return 180;
        case Surface.ROTATION_270:
            return 270;
    }
}
 
开发者ID:angcyo,项目名称:RLibrary,代码行数:19,代码来源:ScreenUtil.java

示例14: getCameraAngle

/**
 * 获取照相机旋转角度
 */
public int getCameraAngle(Activity activity) {
	int rotateAngle = 90;
	CameraInfo info = new CameraInfo();
	Camera.getCameraInfo(cameraId, info);
	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;
	}

	if (info.facing == CameraInfo.CAMERA_FACING_FRONT) {
		rotateAngle = (info.orientation + degrees) % 360;
		rotateAngle = (360 - rotateAngle) % 360; // compensate the mirror
	} else { // back-facing
		rotateAngle = (info.orientation - degrees + 360) % 360;
	}
	return rotateAngle;
}
 
开发者ID:FacePlusPlus,项目名称:MegviiFacepp-Android-SDK,代码行数:33,代码来源:ICamera.java

示例15: getDisplayOrientation

private int getDisplayOrientation(Camera.CameraInfo info, boolean isStillCapture) {
    WindowManager mgr = (WindowManager) ApplicationLoader.applicationContext.getSystemService(Context.WINDOW_SERVICE);
    int rotation = mgr.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;
    }

    int displayOrientation;

    if (info.facing == Camera.CameraInfo.CAMERA_FACING_FRONT) {
        displayOrientation = (info.orientation + degrees) % 360;
        displayOrientation = (360 - displayOrientation) % 360;

        if (!isStillCapture && displayOrientation == 90) {
            displayOrientation = 270;
        }
        if (!isStillCapture && "Huawei".equals(Build.MANUFACTURER) && "angler".equals(Build.PRODUCT) && displayOrientation == 270) {
            displayOrientation = 90;
        }
    } else {
        displayOrientation = (info.orientation - degrees + 360) % 360;
    }

    return displayOrientation;
}
 
开发者ID:pooyafaroka,项目名称:PlusGram,代码行数:38,代码来源:CameraSession.java


注:本文中的android.view.Surface.ROTATION_0属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。