Reputation: 849
So I have some code that takes a photo in a UWP app (running on windows desktops and phones) using this code.
await _mediaCapture.CapturePhotoToStreamAsync(ImageEncodingProperties.CreateJpeg(), stream);
And it works great but it always takes the image at the full resolution of the device... (so 44 megapixels on a Lumia 1020) which is too big for me. I want to limit the resolution to a fixed size (say around 16 megapixel).
So is there a way of setting the camera capture resolution or will I have to capture it at full resolution and downscale it myself?
Upvotes: 3
Views: 3620
Reputation: 29792
You should be able to change resolution of MediaCapture element by setting MediaStreamProperties just after initialization:
// initialization here
// get available resolutions
var resolutions = captureManager.VideoDeviceController.GetAvailableMediaStreamProperties(MediaStreamType.Photo).ToList();
// set used resolution
await captureManager.VideoDeviceController.SetMediaStreamPropertiesAsync(MediaStreamType.Photo, resolutions[1]);
Upvotes: 10