Esempio n. 1
0
        private async void PickPicture()
        {
            var resourceManager = Resource.ResourceManager;

            IsRunning = true;
            try
            {
                var    date      = DateTime.Now;
                string fullName  = "Subien-" + date.Minute + "-" + date.Hour + "-" + date.Day + "-" + Convert.ToString(this.Images.Count() + 1) + ".jpg";
                var    mediaFile = await mediaPicker.SelectPhotoAsync(new CameraMediaStorageOptions
                {
                    DefaultCamera     = CameraDevice.Front,
                    MaxPixelDimension = 400,
                    Name = fullName
                });

                var result = utilities.ImageData(mediaFile.Path, utilities.Path, fullName, 1062, 597);
                if (!result)
                {
                    await dialogService.ShowMessage(resourceManager.GetString("PickPictureTitle"), resourceManager.GetString("PickPicture"), resourceManager.GetString("ConfirmMessageAcept"));
                }

                string fullpath = utilities.Path + "/" + fullName;
                await SavePhoto(fullName, fullpath);
                await AddImageToList(fullName, fullpath);
            }
            catch (System.Exception ex)
            {
                await dialogService.ShowMessage(resourceManager.GetString("PickPictureTitle"), resourceManager.GetString("PickPicture"), resourceManager.GetString("ConfirmMessageAcept"));
            }
            IsRunning = false;
        }
Esempio n. 2
0
        /// <summary>
        /// Selects the picture.
        /// </summary>
        /// <returns>Select Picture Task.</returns>
        private async Task SelectPicture()
        {
            Setup();

            //ImageSource = null;
            try
            {
                var mediaFile = await _mediaPicker.SelectPhotoAsync(new CameraMediaStorageOptions
                {
                    DefaultCamera     = CameraDevice.Front,
                    MaxPixelDimension = 400
                });

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

                //Convert image to string
                FileStream fs        = new FileStream(mediaFile.Path, FileMode.Open, FileAccess.Read);
                byte[]     ImageData = new byte[fs.Length];
                fs.Read(ImageData, 0, System.Convert.ToInt32(fs.Length));
                fs.Close();
                imageString = Convert.ToBase64String(ImageData);

                //Convert string to image

                Byte[] ImageFotoBase64 = System.Convert.FromBase64String(imageString);
                ImageTest = ImageSource.FromStream(() => new MemoryStream(ImageFotoBase64));
            }
            catch (System.Exception ex)
            {
                Status = ex.Message;
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Selects the picture.
        /// </summary>
        /// <returns>Select Picture Task.</returns>
        //public async Task<string> SelectPicture()
        //{
        //    //Setup();

        //    //ImageSource = null;

        //    //         try
        //    //{
        //    //	var mediaFile = await _mediaPicker.SelectPhotoAsync(new CameraMediaStorageOptions
        //    //	{
        //    //		DefaultCamera = CameraDevice.Front,
        //    //		MaxPixelDimension = 400
        //    //	});
        //    //             ImageSource = ImageSource.FromStream(() => mediaFile.Source);



        //    //         }
        //    //catch (System.Exception ex)
        //    //{
        //    //	Status = ex.Message;
        //    //}
        //    return Status = await SelectPicturePath();
        //}
        //public byte[] ReadStream(Stream input)
        //{
        //    byte[] buffer = new byte[16 * 1024];
        //    using (MemoryStream ms = new MemoryStream())
        //    {
        //        int read;
        //        while ((read = input.Read(buffer, 0, buffer.Length)) > 0)
        //        {
        //            ms.Write(buffer, 0, read);
        //        }
        //        return ms.ToArray();
        //    }

        //}
        private async Task <string> SelectPicturePath()
        {
            Setup();

            ImageSource = null;
            //_videoInfo = null;
            try
            {
                var mediaFile = await _mediaPicker.SelectPhotoAsync(new CameraMediaStorageOptions
                {
                    DefaultCamera     = CameraDevice.Front,
                    MaxPixelDimension = 400
                });

                Uri path = new Uri(mediaFile.Path);
                ImageSource = Path.GetFileName(path.AbsoluteUri.ToString());
                byte[] imgData = ReadStream(mediaFile.Source);
                Status = Convert.ToBase64String(imgData);
                //ImageSource = base64String;
                //ImageInfo = base64String;
                //ImageSource = base64String;
            }
            catch (System.Exception ex)
            {
                Status = ex.Message;
            }
            return(Status);
        }
Esempio n. 4
0
        async void btnSelectPicture_Clicked(object sender, EventArgs e)
        {
            var mediaFile = await mediaPicker.SelectPhotoAsync(new CameraMediaStorageOptions());

            Debug.WriteLine($"picture path : {mediaFile.Path}");

            imgPhoto.Source = mediaFile.Path;
        }
Esempio n. 5
0
        async Task SelectPicture()
        {
            Setup();

            ImageSource = null;
            try
            {
                var mediaFile = await _mediaPicker.SelectPhotoAsync(new CameraMediaStorageOptions
                {
                    DefaultCamera     = CameraDevice.Front,
                    MaxPixelDimension = 400
                });

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

            catch (System.Exception ex) { Debug.WriteLine(ex.Message); }
        }
Esempio n. 6
0
        private async Task SelectPicture()
        {
            Setup();

            ImageSource = null;
            try
            {
                var mediaFile = await _mediaPicker.SelectPhotoAsync(new CameraMediaStorageOptions
                {
                    DefaultCamera     = CameraDevice.Front,
                    MaxPixelDimension = 400
                });

                imgSource        = mediaFile.Source;
                ImageSource      = ImageSource.FromStream(() => mediaFile.Source);
                this.ImagenArray = ReadToEnd(mediaFile.Source);
            }
            catch (System.Exception ex)
            {
                Status = ex.Message;
            }
        }
Esempio n. 7
0
        private async Task SelectPicture()
        {
            mediaPicker = DependencyService.Get <IMediaPicker>();

            imageSource = null;

            try
            {
                var mediaFile = await mediaPicker.SelectPhotoAsync(new CameraMediaStorageOptions
                {
                    DefaultCamera     = CameraDevice.Front,
                    MaxPixelDimension = 400
                });

                imageSource = ImageSource.FromStream(() => mediaFile.Source);
                img.Source  = imageSource;
            }
            catch (System.Exception ex)
            {
                this.status = ex.Message;
            }
        }
Esempio n. 8
0
        public async Task SelectPicture()
        {
            Setup();

            ImageSource = null;

            try
            {
                var mediaFile = await _Mediapicker.SelectPhotoAsync(new CameraMediaStorageOptions
                {
                    DefaultCamera     = CameraDevice.Front,
                    MaxPixelDimension = 400
                });

                VideoInfo   = mediaFile.Path;
                ImageSource = ImageSource.FromStream(() => mediaFile.Source);
            }
            catch (System.Exception ex)
            {
                Status = ex.Message;
            }
        }
		private async Task SelectPicture()
		{

			mediaPicker = DependencyService.Get<IMediaPicker>();

			imageSource = null;

			try
			{
				var mediaFile = await mediaPicker.SelectPhotoAsync(new CameraMediaStorageOptions
					{
						DefaultCamera = CameraDevice.Front,
						MaxPixelDimension = 400
					});
				imageSource = ImageSource.FromStream(() => mediaFile.Source);
				img.Source  = imageSource;
			}
			catch (System.Exception ex)
			{
				this.status = ex.Message;
			}
		}
Esempio n. 10
0
        private async void LoadImageButton_OnClicked(object sender, EventArgs e)
        {
            var result = await _mediaPicker.SelectPhotoAsync(new CameraMediaStorageOptions());

            await Recognise(result);
        }