Untitled
Fry
plain_text
a year ago
632 B
27
Indexable
public async Task<Bitmap> GetBitmapFromUrlAsync(string imageUrl)
{
using (HttpClient client = new HttpClient())
{
try
{
byte[] imageBytes = await client.GetByteArrayAsync(imageUrl);
using (MemoryStream ms = new MemoryStream(imageBytes))
{
Bitmap bitmap = new Bitmap(ms);
return bitmap;
}
}
catch (Exception ex)
{
Console.WriteLine($"Error downloading image: {ex.Message}");
return null;
}
}
}Editor is loading...
Leave a Comment