9

我正在使用 CameraCaptureUI 在我的应用程序中打开相机;这是我正在使用的代码

        var camera = new CameraCaptureUI();
        camera.PhotoSettings.AllowCropping = false;
        var file = await camera.CaptureFileAsync(CameraCaptureUIMode.Photo);
        if (file != null)
        {
            var fileStream = await file.OpenAsync(FileAccessMode.Read);
            var bitmapImage = new BitmapImage();
            bitmapImage.SetSource(fileStream);
            var sourceImage = new WriteableBitmap(bitmapImage.PixelWidth, bitmapImage.PixelHeight);
            var imageStream = await file.OpenAsync(FileAccessMode.Read);
            sourceImage.SetSource(imageStream);

        }

但问题不在于相机。在相机打开期间。如果我们打开设置魅力,await 函数会取消 var file = await camera.CaptureFileAsync(CameraCaptureUIMode.Photo);[File 返回 null] 并隐藏 CameraCapture UI。我想要做的是,即使用户打开了魅力,我也需要始终打开我的相机。我如何在 WinRT 中实现这一点

4

1 回答 1

1

要解决您的问题,您需要停止使用CameraCaptureUI并开始<CaptureElement/>在您专门为您的特殊场景设计的 UI 中使用。

我在一篇文章中写了这个来提供帮助。在这里

祝你好运!

于 2013-06-08T06:12:23.530 回答