Win8 使用照相机获取照片,视频等效

来源:互联网 发布:田宫上色 知乎 编辑:程序博客网 时间:2024/04/20 17:25
// 添加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)            {                // 保存图片            }        }


 

原创粉丝点击