Share via

Save Image from Source to Device

jrahma 116 Reputation points
2021-04-16T16:35:33.837+00:00

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

Developer technologies | .NET | Xamarin
Developer technologies | C#
Developer technologies | C#

An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.

0 comments No comments

1 answer

Sort by: Most helpful
  1. DonR 26 Reputation points
    2021-04-16T16:49:18.58+00:00

    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);
    

    Was this answer helpful?

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.