我正在使用 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 中实现这一点