0

I have a project that captures the image using camera.

After capturing the image it will display in my view.

what I need to do is to get the attached image in my view and convert it to Base64.

My View:

 <StackLayout Orientation="Horizontal"> <Label x:Name="CaptureLabel" Text="Capture Image:" TextColor="Black" FontSize="12" Margin="20,10,0,0" VerticalOptions="StartAndExpand" HorizontalOptions="Start"></Label> <Image x:Name="CameraButton" Margin="20,5,15,0" HorizontalOptions="EndAndExpand"> <Image.GestureRecognizers> <TapGestureRecognizer Tapped="TapGestureRecognizer_Tapped"/> </Image.GestureRecognizers> </Image> </StackLayout> 

My Code Behind:

 private async void TapGestureRecognizer_Tapped(object sender, EventArgs e) { var photo = await Media.Plugin.CrossMedia.Current.TakePhotoAsync(new Media.Plugin.Abstractions.StoreCameraMediaOptions() { }); if (photo != null) CameraButton.Source = ImageSource.FromStream(() => { return photo.GetStream(); }); CameraButton.HeightRequest = 80; CameraButton.WidthRequest = 50; MainStack.HeightRequest = 470; } 
4
  • Convert it while you still have access to it via your photo instance. Commented Dec 11, 2017 at 8:07
  • Do you have any steps on how to convert and image to base64 in xamarin? Commented Dec 11, 2017 at 8:20
  • msdn.microsoft.com/en-us/library/dhx0d524(v=vs.110).aspx Commented Dec 11, 2017 at 8:27
  • You can also see this: https://stackoverflow.com/questions/17874733/converting-image-to-base64 and this https://stackoverflow.com/questions/15089359/how-to-convert-image-png-to-base64-string-vice-a-versa-and-strore-it-to-a-sp. Commented Dec 11, 2017 at 9:00

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.