app/src/main/java/cn/lytcom/camera2kit/Camera2Fragment.java
/**
     * Configures the necessary {@link 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`
     */
Configures the necessary  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`
Configures the necessary 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);
    }
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 ) ; }
Configures the necessary {@link Matrix} transformation to `mTextureView`.
Configures the necessary { @link Matrix } transformation to ` mTextureView ` .