Forum Xamarin.Forms
We are excited to announce that the Xamarin Forums are moving to the new Microsoft Q&A experience. Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

We encourage you to head over to Microsoft Q&A for .NET for posting new questions and get involved today.

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()
            ImageSource = null;
                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.