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