예제 #1
0
 /// <summary>
 /// control the camera frame invert , flip to the mirror image
 /// </summary>
 private async Task SetPreviewRotationAsync()
 {
     if (!_externalCamera)
     {
         // Add rotation metadata to the preview stream to make sure the aspect ratio / dimensions match when rendering and getting preview frames
         var  rotation    = _rotationHelper.GetCameraPreviewOrientation();
         var  props       = _mediaCapture.VideoDeviceController.GetMediaStreamProperties(MediaStreamType.VideoPreview);
         Guid RotationKey = new Guid("C380465D-2271-428C-9B83-ECEA3B4A85C1");
         props.Properties.Add(RotationKey, CameraRotationHelper.ConvertSimpleOrientationToClockwiseDegrees(rotation));
         await _mediaCapture.SetEncodingPropertiesAsync(MediaStreamType.VideoPreview, props, null);
     }
 }
예제 #2
0
        private async void RotationHelper_OrientationChanged(object sender, bool updatePreview)
        {
            if (updatePreview)
            {
                await SetPreviewRotationAsync();
            }
            await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => {
                // Rotate the buttons in the UI to match the rotation of the device
                var angle     = CameraRotationHelper.ConvertSimpleOrientationToClockwiseDegrees(_rotationHelper.GetUIOrientation());
                var transform = new RotateTransform {
                    Angle = angle
                };

                // The RenderTransform is safe to use (i.e. it won't cause layout issues) in this case, because these buttons have a 1:1 aspect ratio
                //CapturePhotoButton.RenderTransform = transform;
                //CapturePhotoButton.RenderTransform = transform;
            });
        }