转换"Xamarin.Form.Image"类型为"byte []" [英] Convert 'Xamarin.Form.Image' type 'byte[]'
本文介绍了转换"Xamarin.Form.Image"类型为"byte []"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我应该从URL获取图像并将其转换为byte[]
.以下是我取得的成就
I am supposed to get an Image from a url and convert it into byte[]
. The following is what I achieved
var webImage = new Image { Aspect = Aspect.AspectFit };
webImage.Source = ImageSource.FromUri(new Uri("http://xamarin.com/content/images/pages/forms/example-app.png"));
但是现在我无法将图像类型转换为byte[]
.
but now I am unable to convert the Image type to byte[]
.
这是正确的方法吗?任何帮助将不胜感激.
Is this the correct way to approach? Any kind of help would be appreciated.
推荐答案
可以使用WebClient从URL获取字节数组.
It's posible to use WebClient to obtain byte array from a URL.
var webClient = new WebClient ();
byte[] byteImage = webClient.DownloadData (imageURL);
这篇关于转换"Xamarin.Form.Image"类型为"byte []"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文