question

10918804 avatar image
0 Votes"
10918804 asked DonR-8455 answered

Save Image from Source to Device

Hi,

I have the following:

 <Image x:Name="MyImage" Source="{Binding image}">
 <Image.GestureRecognizers>
     <TapGestureRecognizer Tapped="SaveOnPhotoTapped" NumberOfTapsRequired="1" />
 </Image.GestureRecognizers>
 </Image>



How can I save that image from the Source to the local device?


Thanks,
Jassim



dotnet-csharpdotnet-xamarin
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

DonR-8455 avatar image
0 Votes"
DonR-8455 answered

One way I've had success saving binary data as a local file on a mobile device is to convert the data to Byte[], base64 encode that, and set a preference with that string as the value:

 Xamarin.Essentials.Preferences.Set(nameOfPreference, System.Convert.ToBase64String(imageDataAsByteArray);

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.