VoiceCamera.CameraFragment.ConfigureTransform C# (CSharp) 메소드

ConfigureTransform() 개인적인 메소드

Configures the necessary transformation to mTextureView. This method should be called after the camera preciew size is determined in openCamera, and also the size of mTextureView is fixed
private ConfigureTransform ( int viewWidth, int viewHeight ) : void
viewWidth int The width of mTextureView
viewHeight int VThe height of mTextureView
리턴 void
        private void ConfigureTransform(int viewWidth, int viewHeight)
        {
            Activity activity = Activity;
            if (mTextureView == null || mPreviewSize == null || activity == null) {
                return;
            }

            SurfaceOrientation rotation = activity.WindowManager.DefaultDisplay.Rotation;
            Matrix matrix = new Matrix ();
            RectF viewRect = new RectF (0, 0, viewWidth, viewHeight);
            RectF bufferRect = new RectF (0, 0, mPreviewSize.Width, mPreviewSize.Height);
            float centerX = viewRect.CenterX();
            float centerY = viewRect.CenterY();
            if (rotation == SurfaceOrientation.Rotation90 || rotation == SurfaceOrientation.Rotation270) {
                bufferRect.Offset (centerX - bufferRect.CenterX(), centerY - bufferRect.CenterY());
                matrix.SetRectToRect (viewRect, bufferRect, Matrix.ScaleToFit.Fill);
                float scale = System.Math.Max ((float)viewHeight / mPreviewSize.Height, (float)viewWidth / mPreviewSize.Width);
                matrix.PostScale (scale, scale, centerX, centerY);
                matrix.PostRotate (90 * ((int)rotation - 2), centerX, centerY);
            }
            mTextureView.SetTransform (matrix);
        }

Usage Example

예제 #1
0
 public void OnSurfaceTextureAvailable(Android.Graphics.SurfaceTexture surface, int width, int height)
 {
     Fragment.ConfigureTransform(width, height);
     Fragment.StartPreview();
 }