CapturedPhoto.Frame.SoftwareBitmap 为空

CapturedPhoto.Frame.SoftwareBitmap is null

我正在尝试使用 AdvancedPhotoCapture 获取 SoftwareBitmap,但生成的 CapturedPhoto.Frame.SoftwareBitmap 为空。如何获得 SoftwareBitmap 以便将其显示到屏幕上?

//create mediacapture
mediaCapture = new MediaCapture();
await mediaCapture.InitializeAsync();

// check if supported
var settings = new AdvancedPhotoCaptureSettings
{
    Mode = AdvancedPhotoMode.Standard
};

//configure capture
if (!mediaCapture.VideoDeviceController.AdvancedPhotoControl.SupportedModes.Contains(settings.Mode))
{
    Debug.WriteLine("Mode not supported");
    return;
}
mediaCapture.VideoDeviceController.AdvancedPhotoControl.Configure(settings);
var adv = await mediaCapture.PrepareAdvancedPhotoCaptureAsync(ImageEncodingProperties.CreateJpeg());

// take photo
var capturedPhoto = await adv.CaptureAsync();
Debug.WriteLine(capturedPhoto.Frame.SoftwareBitmap == null);

替换

ImageEncodingProperties.CreateJpeg()

ImageEncodingProperties.CreateUncompressed(MediaPixelFormat.Bgra8)

对于 AdvancedPhotoCapture、VariablePhotoSequence、LowLagCaptureSequence 等,只有在使用未压缩格式编码时才会填充 SoftwareBitmap。