How to Convert ImageSource to Byte ??

KaushalDevlukKaushalDevluk INMember
edited January 2017 in Xamarin.Forms

I want to take pic from camera or select pic from gallery and assign stream to image source i also get stream but i want this image into base64string so any have a idea to how to convert it.??
My Code is:

Xaml File:

  <Image Source="{Binding ImageSource}"
               VerticalOptions="CenterAndExpand" />

and CS file is :

private async Task SelectPicture()
        {
            Setup();
            ImageSource = null;
            try
            {
                var mediaFile = await _mediaPicker.SelectPhotoAsync(new CameraMediaStorageOptions
                {
                    DefaultCamera = CameraDevice.Rear,
                    MaxPixelDimension = 400,
                    SaveMediaOnCapture = true
                });


                ImageSource = ImageSource.FromStream(() => mediaFile.Source);
            }
            catch (System.Exception ex)
            {
                Status = ex.Message;
            }
        }
Sign In or Register to comment.