// 添加
using Windows.Media.Capture;
private async void OnCapturePhoto(object sender, TappedRoutedEventArgs e)
{
var camera = new CameraCaptureUI();
camera.PhotoSettings.AllowCropping = false; // 不允许裁剪
Size newsize = new Size(50,100);
camera.PhotoSettings.CroppedAspectRatio = newsize;// 设置裁剪宽、高比例
camera.PhotoSettings.CroppedSizeInPixels = newsize;// 设置 裁剪尺寸
camera.PhotoSettings.Format = CameraCaptureUIPhotoFormat.Png;// 设置照片格式
camera.PhotoSettings.MaxResolution = CameraCaptureUIMaxPhotoResolution.HighestAvailable;// 设置分辨率
StorageFile file = await camera.CaptureFileAsync(CameraCaptureUIMode.Photo); // 打开相机,获取照片
if (file != null)
{
// 保存图片
}
}