當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。