Image from URL to stream

前端 未结 3 2145
后悔当初
后悔当初 2020-12-18 19:50

I\'m getting images from a url:

BitmapImage image = new BitmapImage(new Uri(article.ImageURL));
NLBI.Thumbnail.Source = image;

This works p

3条回答
  •  天命终不由人
    2020-12-18 20:18

    you can use this:

        private async Task GetImageAsByteArray(string urlImage, string urlBase)
        {
    
            var client = new HttpClient();
            client.BaseAddress = new Uri(urlBase);
            var response = await client.GetAsync(urlImage);
    
            return await response.Content.ReadAsByteArrayAsync();
        }
    

提交回复
热议问题