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


Java Surface.ROTATION_180属性代码示例

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


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

示例1: getDisplayRotation

private int getDisplayRotation(Context context) {
    WindowManager windowManager = (WindowManager) context
            .getSystemService(Context.WINDOW_SERVICE);
    int rotation = windowManager.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;
    }
    return 0;
}
 
开发者ID:uelordi01,项目名称:Android-opencv-native-samples,代码行数:16,代码来源:ImageControllers.java

示例2: initRotateDegree

void initRotateDegree(int cameraId) {
    Camera.CameraInfo info = new Camera.CameraInfo();
    Camera.getCameraInfo(cameraId, info);
    log.debug("cameraId: " + cameraId + ", rotation: " + info.orientation);
    int rotation = mActivity.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;
    }
    mDisplayRotate = (info.orientation - degrees + 360) % 360;
}
 
开发者ID:zhangyaqiang,项目名称:Fatigue-Detection,代码行数:22,代码来源:CameraLoader.java

示例3: getDirectionFromOrientation

private int getDirectionFromOrientation() {
    int rotation = mWm.getDefaultDisplay().getRotation();
    switch (rotation) {
        case Surface.ROTATION_0:
            if (DEBUG) log("Rotation = 0");
            return 1;
        case Surface.ROTATION_90:
            if (DEBUG) log("Rotation = 90");
            return -1;
        case Surface.ROTATION_180:
            if (DEBUG) log("Rotation = 180");
            return -1;
        case Surface.ROTATION_270:
        default:
            if (DEBUG) log("Rotation = 270");
            return 1;
    }
}
 
开发者ID:WrBug,项目名称:GravityBox,代码行数:18,代码来源:ModAudio.java

示例4: getCameraDisplayOrientation

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;   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;
  }
}
 
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:22,代码来源:CameraUtils.java

示例5: 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:lgyjg,项目名称:AndroidRTC,代码行数:21,代码来源:VideoCapturerAndroid.java

示例6: getRotationState

public static RotationState getRotationState(@NonNull Context context) {
    final int rotation = ((WindowManager) context.getSystemService(Context.WINDOW_SERVICE))
            .getDefaultDisplay().getRotation();
    switch (rotation) {
        case Surface.ROTATION_0:
            return RotationState.PORTRAIT;
        case Surface.ROTATION_90:
            return RotationState.LANDSCAPE;
        case Surface.ROTATION_180:
            return RotationState.REVERSE_PORTRAIT;
        case Surface.ROTATION_270:
            return RotationState.REVERSE_LANDSCAPE;
        default:
            return RotationState.UNKNOWN;
    }
}
 
开发者ID:owniz,项目名称:OzComicReader,代码行数:16,代码来源:RotationUtils.java

示例7: 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

示例8: getOrientationInDegree

public static int getOrientationInDegree(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;
        }

        return degrees;
    }
 
开发者ID:SalmanTKhan,项目名称:MyAnimeViewer,代码行数:23,代码来源:CropUtil.java

示例9: configureTransform

/**
 * Configures the necessary {@link android.graphics.Matrix} transformation to `mTextureView`.
 * This method should be called after the camera preview size is determined in
 * setUpCameraOutputs and also the size of `mTextureView` is fixed.
 *
 * @param viewWidth The width of `mTextureView`
 * @param viewHeight The height of `mTextureView`
 */
private void configureTransform(final int viewWidth, final int viewHeight) {
  final Activity activity = getActivity();
  if (null == textureView || null == previewSize || null == activity) {
    return;
  }
  final int rotation = activity.getWindowManager().getDefaultDisplay().getRotation();
  final Matrix matrix = new Matrix();
  final RectF viewRect = new RectF(0, 0, viewWidth, viewHeight);
  final RectF bufferRect = new RectF(0, 0, previewSize.getHeight(), previewSize.getWidth());
  final float centerX = viewRect.centerX();
  final float centerY = viewRect.centerY();
  if (Surface.ROTATION_90 == rotation || Surface.ROTATION_270 == rotation) {
    bufferRect.offset(centerX - bufferRect.centerX(), centerY - bufferRect.centerY());
    matrix.setRectToRect(viewRect, bufferRect, Matrix.ScaleToFit.FILL);
    final float scale = Math.max((float) viewHeight / previewSize.getHeight(),
        (float) viewWidth / previewSize.getWidth());
    matrix.postScale(scale, scale, centerX, centerY);
    matrix.postRotate(90 * (rotation - 2), centerX, centerY);
  } else if (Surface.ROTATION_180 == rotation) {
    matrix.postRotate(180, centerX, centerY);
  }
  textureView.setTransform(matrix);
}
 
开发者ID:flipper83,项目名称:SortingHatAndroid,代码行数:31,代码来源:CameraConnectionFragment.java

示例10: configureTransform

/**
 * Configures the necessary {@link android.graphics.Matrix} transformation to `mTextureView`.
 * This method should be called after the camera preview size is determined in
 * setUpCameraOutputs and also the size of `mTextureView` is fixed.
 *
 * @param viewWidth  The width of `mTextureView`
 * @param viewHeight The height of `mTextureView`
 */
private void configureTransform(final int viewWidth, final int viewHeight) {
  final Activity activity = getActivity();
  if (null == textureView || null == previewSize || null == activity) {
    return;
  }
  final int rotation = activity.getWindowManager().getDefaultDisplay().getRotation();
  final Matrix matrix = new Matrix();
  final RectF viewRect = new RectF(0, 0, viewWidth, viewHeight);
  final RectF bufferRect = new RectF(0, 0, previewSize.getHeight(), previewSize.getWidth());
  final float centerX = viewRect.centerX();
  final float centerY = viewRect.centerY();
  if (Surface.ROTATION_90 == rotation || Surface.ROTATION_270 == rotation) {
    bufferRect.offset(centerX - bufferRect.centerX(), centerY - bufferRect.centerY());
    matrix.setRectToRect(viewRect, bufferRect, Matrix.ScaleToFit.FILL);
    final float scale =
        Math.max(
            (float) viewHeight / previewSize.getHeight(),
            (float) viewWidth / previewSize.getWidth());
    matrix.postScale(scale, scale, centerX, centerY);
    matrix.postRotate(90 * (rotation - 2), centerX, centerY);
  } else if (Surface.ROTATION_180 == rotation) {
    matrix.postRotate(180, centerX, centerY);
  }
  textureView.setTransform(matrix);
}
 
开发者ID:apacha,项目名称:TensorflowAndroidDemo,代码行数:33,代码来源:CameraConnectionFragment.java

示例11: setDisplayOrientation

private void setDisplayOrientation() {
    // Uses window manager to get current window rotation, and rotates camera image accordingly
    final int rotation = mActivity.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;
    }

    final int displayOrientation = (mBackCameraInfo.orientation
            - degrees + 360) % 360;
    mCamera.setDisplayOrientation(displayOrientation);
}
 
开发者ID:csarron,项目名称:renderscript_examples,代码行数:24,代码来源:CameraHandler.java

示例12: getCurrentOrientation

private String getCurrentOrientation() {

        final Display display = ((WindowManager) getReactApplicationContext().getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();

        switch (display.getRotation()) {
            case Surface.ROTATION_0:
                return "PORTRAIT";
            case Surface.ROTATION_90:
                return "LANDSCAPE-RIGHT";
            case Surface.ROTATION_180:
                return "PORTRAIT-UPSIDEDOWN";
            case Surface.ROTATION_270:
                return "LANDSCAPE-LEFT";
        }
        return "UNKNOWN";
    }
 
开发者ID:wonday,项目名称:react-native-orientation-locker,代码行数:16,代码来源:OrientationModule.java

示例13: setCameraDisplayOrientation

private 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;
            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);
}
 
开发者ID:dazcode,项目名称:smart-device-cloud,代码行数:29,代码来源:SmartCamera.java

示例14: getDisplayOrientation

public int getDisplayOrientation() {
    Camera.CameraInfo info = new Camera.CameraInfo();
    Camera.getCameraInfo(Camera.CameraInfo.CAMERA_FACING_BACK, info);
    WindowManager wm = (WindowManager) getContext().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:angcyo,项目名称:RLibrary,代码行数:32,代码来源:RCameraPreview.java

示例15: onMeasure

@SuppressWarnings("SuspiciousNameCombination")
@Override
public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
    if (display.getRotation() == Surface.ROTATION_0 || display.getRotation() == Surface.ROTATION_180) {
        super.onMeasure(widthMeasureSpec, widthMeasureSpec);
    } else {
        super.onMeasure(heightMeasureSpec, heightMeasureSpec);
    }
}
 
开发者ID:lucasax,项目名称:Zero,代码行数:9,代码来源:SquareVideoView.java


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