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; }
photoinstance.https://stackoverflow.com/questions/17874733/converting-image-to-base64and thishttps://stackoverflow.com/questions/15089359/how-to-convert-image-png-to-base64-string-vice-a-versa-and-strore-it-to-a-sp.