コード例 #1
0
        private async Task <MediaFile> TakePicture()
        {
            Setup();

            ImageSource = null;
            _imgstream  = null;
            return(await _mediaPicker.TakePhotoAsync(new CameraMediaStorageOptions { DefaultCamera = CameraDevice.Front, MaxPixelDimension = 400, SaveMediaOnCapture = true, Directory = "Images", Name = Guid.NewGuid().ToString() }).ContinueWith(t =>
            {
                if (t.IsFaulted)
                {
                    Status = t.Exception.InnerException.ToString();
                }
                else if (t.IsCanceled)
                {
                    Status = "Canceled";
                }
                else
                {
                    var mediaFile = t.Result;
                    MemoryStream ms = new MemoryStream();
                    mediaFile.Source.CopyTo(ms);
                    _imgstream = ms.ToArray();

                    ImageSource = ImageSource.FromStream(() => mediaFile.Source);
                    return mediaFile;
                }

                return null;
            }, _scheduler));
        }
コード例 #2
0
        /// <summary>
        /// Takes the picture.
        /// </summary>
        /// <returns>Take Picture Task.</returns>
        private async Task <MediaFile> TakePicture()
        {
            Setup();

            ImageSource = null;

            return(await _mediaPicker.TakePhotoAsync(new CameraMediaStorageOptions { DefaultCamera = CameraDevice.Front, MaxPixelDimension = 400 }).ContinueWith(t =>
            {
                if (t.IsFaulted)
                {
                    Status = t.Exception.InnerException.ToString();
                }
                else if (t.IsCanceled)
                {
                    Status = "Canceled";
                }
                else
                {
                    var mediaFile = t.Result;

                    ImageSource = ImageSource.FromStream(() => mediaFile.Source);

                    return mediaFile;
                }

                return null;
            }, _scheduler));
        }