Replies: 2 comments 3 replies
-
facing exactly the same situation. loading file from Web |
Beta Was this translation helpful? Give feedback.
1 reply
-
Hi, @mach-9
Simply bind or set the above ImageSource to the Image control's Source property. |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I'm new to mobile development with .NET Maui, and trying to display a picture (.jpg) from an API that I created.
I'm having issues with trying to display the byte array returned from my web API on a .NET Maui page. I've followed the Community Toolkit Maui sample project (ByteArrayToImageSourceConverterPage), and only changed the client call to my web API, see code below:
Community Toolkit Maui sample code
DotNetBotImageByteArray = await client.GetByteArrayAsync("https://user-images.githubusercontent.com/13558917/137551073-ac8958bf-83e3-4ae3-8623-4db6dce49d02.png", cancellationTokenSource.Token).ConfigureAwait(false);
To:
DotNetBotImageByteArray = await client.GetByteArrayAsync("http://XXX.XXX.XXX/api/[controller name]/[Method]/{[value]}", cancellationTokenSource.Token).ConfigureAwait(false);
The web API returns the byte array: byte[] results = _IService.GetImageAsync([value]);
I've tried to change the API to return ToBase64String and Maui to FromBase64String, too many other options to list, googled the heck out of it, and having no success.
Another option would be to FileWrite the bytes from the API to a folder on the phone, and then display the photo from the folder. Doesn't make sense to me that I should have to do that, all I need is the byte array from the API, store it in a variable, and bind it to the image.
I'm currently using the toolkit sample project so I haven't changed anything, just added my call to the API instead.
Using VS2022, and developing an android application using a simulator.
Any help on this would be much appreciated.
Thank you.
Beta Was this translation helpful? Give feedback.
All reactions