Untitled
Fry
plain_text
16 days ago
632 B
20
Indexable
Never
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; } } }
Leave a Comment