Maui - show Image from string base 64

Dani_S 4,501 Reputation points
2023-11-07T07:48:48.9366667+00:00

Hi,

I have base 64 string , how i show it in image control?

Thanks,

Developer technologies | .NET | .NET MAUI
{count} votes

Accepted answer
  1. Anonymous
    2023-11-08T01:21:16.7466667+00:00

    Hello,

    You can convert base64 string to byte[] by Convert.FromBase64String(String) Method, then read byte[] to stream, set the stream to the imagesource like following code.

    ImageSource.FromStream(() => new MemoryStream(Convert.FromBase64String(base64String)));
    

    If you are using MVVM, you can set the ImageSource to your property in the viewmodel.

    Best Regards,

    Leon Lu


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    1 person found this answer helpful.
    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

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