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


Java Surface.ROTATION_270属性代码示例

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


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

示例1: configureTransform

/**
 * 在确定相机预览大小后应调用此方法
 *
 * @param viewWidth  宽
 * @param viewHeight 高
 */
private void configureTransform(int viewWidth, int viewHeight) {
    if (null == mPreviewSize) {
        return;
    }
    int rotation = getDisplayRotation();
    Matrix matrix = new Matrix();
    RectF viewRect = new RectF(0, 0, viewWidth, viewHeight);
    RectF bufferRect = new RectF(0, 0, mPreviewSize.getHeight(), mPreviewSize.getWidth());
    float centerX = viewRect.centerX();
    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);
        float scale = Math.max(
                (float) viewHeight / mPreviewSize.getHeight(),
                (float) viewWidth / mPreviewSize.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);
    }
    this.setTransform(matrix);
}
 
开发者ID:shenhuanet,项目名称:Ocr-android,代码行数:29,代码来源:CameraPreview.java

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

示例3: 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(int viewWidth, int viewHeight) {
    Activity activity = getActivity();
    if (null == mTextureView || null == mPreviewSize || null == activity) {
        return;
    }
    int rotation = activity.getWindowManager().getDefaultDisplay().getRotation();
    Matrix matrix = new Matrix();
    RectF viewRect = new RectF(0, 0, viewWidth, viewHeight);
    RectF bufferRect = new RectF(0, 0, mPreviewSize.getHeight(), mPreviewSize.getWidth());
    float centerX = viewRect.centerX();
    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);
        float scale = Math.max(
                (float) viewHeight / mPreviewSize.getHeight(),
                (float) viewWidth / mPreviewSize.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);
    }
    mTextureView.setTransform(matrix);
}
 
开发者ID:neural-nuts,项目名称:Cam2Caption,代码行数:32,代码来源:Camera2BasicFragment.java

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

示例5: 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:Jamjomjara,项目名称:snu-artoon,代码行数:33,代码来源:CameraConnectionFragment.java

示例6: 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:entria,项目名称:react-native-camera-face-detector,代码行数:18,代码来源:RCTSensorOrientationChecker.java

示例7: getScreenRotationAngle

/**
 * 获取屏幕旋转角度
 *
 * @param activity activity
 * @return 屏幕旋转角度
 */
public static int getScreenRotationAngle(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:Ayvytr,项目名称:EasyAndroid,代码行数:21,代码来源:ScreenTool.java

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

示例9: getDisplayOrientation

private int getDisplayOrientation(){
    WindowManager windowManager = getWindowManager();
    Display display = windowManager.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;
    }

    android.hardware.Camera.CameraInfo camInfo =
            new android.hardware.Camera.CameraInfo();
    android.hardware.Camera.getCameraInfo(Camera.CameraInfo.CAMERA_FACING_BACK, camInfo);

    // camInfo方向
    int result = (camInfo.orientation - degrees + 360) % 360;

    return result;
}
 
开发者ID:kagurazakayashi,项目名称:achoosephoto,代码行数:29,代码来源:MainActivity.java

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

示例11: setCameraDisplayOrientation

/**
     * Starting from API level 14, this method can be called when preview is
     * active.
     *
     * @param context
     * @param camera
     */
    static void setCameraDisplayOrientation(Context context, android.hardware.Camera camera, int cameraId) {
        if (camera == null || context == null) {
            return;
        }

        Camera.CameraInfo info = getCameraInfo(cameraId);
        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 (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;
        }
//        Starting from API level 14, this method can be called when preview is active.
        camera.setDisplayOrientation(result);
    }
 
开发者ID:android-notes,项目名称:CameraPreview,代码行数:39,代码来源:CameraUtils.java

示例12: 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`
 */
@DebugLog
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:SimonCherryGZ,项目名称:face-landmark-android,代码行数:34,代码来源:CameraConnectionFragment.java

示例13: calculateDisplayRotation

private int calculateDisplayRotation() {
    // http://developer.android.com/reference/android/hardware/Camera.html#setDisplayOrientation(int)
    int rotation = displayConfiguration.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 (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;
    }
    Log.i(TAG, "Camera Display Orientation: " + result);
    return result;
}
 
开发者ID:yinhaojun,项目名称:ZxingForAndroid,代码行数:29,代码来源:CameraManager.java

示例14: fixLayoutInternal

private void fixLayoutInternal() {
    if (getParentActivity() == null) {
        return;
    }
    int position = listView.getFirstVisiblePosition();
    WindowManager manager = (WindowManager) ApplicationLoader.applicationContext.getSystemService(Activity.WINDOW_SERVICE);
    int rotation = manager.getDefaultDisplay().getRotation();

    int columnsCount;
    if (AndroidUtilities.isTablet()) {
        columnsCount = 3;
    } else {
        if (rotation == Surface.ROTATION_270 || rotation == Surface.ROTATION_90) {
            columnsCount = 5;
        } else {
            columnsCount = 3;
        }
    }
    listView.setNumColumns(columnsCount);
    if (AndroidUtilities.isTablet()) {
        itemWidth = (AndroidUtilities.dp(490) - ((columnsCount + 1) * AndroidUtilities.dp(4))) / columnsCount;
    } else {
        itemWidth = (AndroidUtilities.displaySize.x - ((columnsCount + 1) * AndroidUtilities.dp(4))) / columnsCount;
    }
    listView.setColumnWidth(itemWidth);

    listAdapter.notifyDataSetChanged();
    listView.setSelection(position);

    if (selectedAlbum == null) {
        emptyView.setPadding(0, 0, 0, (int) ((AndroidUtilities.displaySize.y - ActionBar.getCurrentActionBarHeight()) * 0.4f));
    }
}
 
开发者ID:pooyafaroka,项目名称:PlusGram,代码行数:33,代码来源:PhotoPickerActivity.java

示例15: 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:Jay-Ping,项目名称:newIPlay,代码行数:19,代码来源:ScreenUtils.java


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