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