[英]How to change media capture photo resolution for UWP?
So I have some code that takes a photo in a UWP app (running on windows desktops and phones) using this code. 所以我有一些代码可以使用此代码在UWP应用程序(在Windows桌面和手机上运行)中拍照。
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. 它的效果很好,但它总是以设备的全分辨率拍摄图像......(Lumia 1020上的44万像素)对我来说太大了。 I want to limit the resolution to a fixed size (say around 16 megapixel).
我想将分辨率限制在固定大小(比如大约1600万像素)。
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? 那么有没有办法设置相机捕获分辨率,还是我必须以全分辨率捕获它并自己缩小尺寸?
You should be able to change resolution of MediaCapture element by setting MediaStreamProperties just after initialization: 您应该能够通过在初始化之后设置MediaStreamProperties来更改MediaCapture元素的分辨率:
// initialization here
// get available resolutions
var resolutions = captureManager.VideoDeviceController.GetAvailableMediaStreamProperties(MediaStreamType.Photo).ToList();
// set used resolution
await captureManager.VideoDeviceController.SetMediaStreamPropertiesAsync(MediaStreamType.Photo, resolutions[1]);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.