using Avalonia.Media.Imaging; using SkiaSharp; using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.IO; using System.Linq; using System.Net.Http; using System.Text; using System.Threading.Tasks; namespace demo_trade.Utils { public static class ImageHelper { public static string BASE_URL = "http://localhost:5025/images"; public static async Task LoadFromRemoteByName(string imageName) { if (String.IsNullOrWhiteSpace(imageName)) imageName = "default.png"; using var httpClient = new HttpClient(); try { var response = await httpClient.GetAsync(BASE_URL + "/" + imageName); var data = await response.Content.ReadAsByteArrayAsync(); var bimap = new Bitmap(new MemoryStream(data)); bimap.Save(imageName); return new Bitmap(new MemoryStream(data)); } catch (Exception ex) { return null; } } } }