Image to byte array from a url
WebClient.DownloadData
is the easiest way.
string someUrl = "http://www.google.com/images/logos/ps_logo2.png";
using (var webClient = new WebClient()) {
byte[] imageBytes = webClient.DownloadData(someUrl);
}
If you need an asynchronous version:
using (var client = new HttpClient())
{
using (var response = await client.GetAsync(url))
{
byte[] imageBytes =
await response.Content.ReadAsByteArrayAsync().ConfigureAwait(false);
}
}