CameraCaptureUI control size of popup?

2019-07-28 03:20发布

问题:

A couple of questions about CameraCaptureUI.

1) Can I control the size/placement of the popup? It pops up very small on my Win10 tablet and it's really annoying to enlarge it each time the app needs to take a photo!

2) I am trying to create photos that are equivalent in quality to the built-in camera app, but I had a lot of trouble with this. Only by playing around with the croppedSizeInPixels could I get anything larger that seemed decent quality. Can someone explain why this helped and if there's a better way to increase the quality of the photo? The builtin app creates 2592x1944 pixel images approx 1MB large by default. IF this is the right way should I be calculating these dimensions somehow?

captureUI = new CameraCaptureUI();
captureUI.PhotoSettings.Format = CameraCaptureUIPhotoFormat.Jpeg;
captureUI.PhotoSettings.AllowCropping = true;
captureUI.PhotoSettings.MaxResolution = CameraCaptureUIMaxPhotoResolution.HighestAvailable;

// photo created is approx 576KB
captureUI.PhotoSettings.CroppedSizeInPixels = new Size(3840, 2160);    

回答1:

1) Can I control the size/placement of the popup?

As you can see, there is no API in CameraCaptureUI class can control the size/placement of the camera capture UI. For Windows 8.1, this class provides a full window UI for capturing audio, video, and photos from a camera. However, in Windows 10, it's a popup windows. Actually, this class launches the built-in Camera app for capturing, you can find this in Task Manager.

If CameraCaptureUI can't meet your requirement and you want more robust, low-level control of the capture operation, you should use the MediaCapture object and implement your own capture experience. For more information, see Capture photos and video with MediaCapture.

2) I am trying to create photos that are equivalent in quality to the built-in camera app.

CameraCaptureUI class actually launches the built-in Camera app for capturing and it doesn't provide much ways to specify properties for the returned photo. We can only use CroppedSizeInPixels to specify the resolution of the captured photo. We can set this property to a large enough value. If a size is specified that is larger than any available resolution, then the captured photo will be scaled to a large enough size first. If you want to control the resolution of the captured picture, I'd also recommend using MediaCapture with GetMediaStreamProperties and SetMediaStreamPropertiesAsync methods. For more info, please see Camera resolution sample.