0
這是我的代碼如何將流轉換爲BitmapImage的
private async void OnGetImage(object sender, RoutedEventArgs e)
{
using (HttpClient client = new HttpClient())
{
try
{
HttpResponseMessage response = await client.GetAsync(new Uri(txtUri.Text));
BitmapImage bitmap = new BitmapImage();
if (response != null && response.StatusCode == HttpStatusCode.OK)
{
using (InMemoryRandomAccessStream stream = new InMemoryRandomAccessStream())
{
await response.Content.WriteToStreamAsync(stream);
stream.Seek(0UL);
bitmap.SetSource(stream);
}
this.img.Source = bitmap;
}
}
catch (Exception)
{
throw;
}
}
}
,但現在我不能在UWP使用WriteToStreamAsync(),誰可以幫幫我嗎?
你很聰明,它的工作原理 –