Reputation: 380
I am trying to use AdvancedPhotoCapture to get a SoftwareBitmap but the resulting CapturedPhoto.Frame.SoftwareBitmap is null. How can I get a SoftwareBitmap so I can display it to screen?
//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);
Upvotes: 0
Views: 391
Reputation: 380
Replace
ImageEncodingProperties.CreateJpeg()
with
ImageEncodingProperties.CreateUncompressed(MediaPixelFormat.Bgra8)
For AdvancedPhotoCapture, VariablePhotoSequence, LowLagCaptureSequence, etc. the SoftwareBitmap will only be populated when encoding with an uncompressed format.
Upvotes: 1