Revision: 56378
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at March 24, 2012 04:21 by ryanfiorini
Initial Code
public byte[] getImageFromUrl(string url) { System.Net.HttpWebRequest request = null; System.Net.HttpWebResponse response = null; byte[] b = null; request = (System.Net.HttpWebRequest)System.Net.WebRequest.Create(url); response = (System.Net.HttpWebResponse)request.GetResponse(); if (request.HaveResponse) { if (response.StatusCode == System.Net.HttpStatusCode.OK) { Stream receiveStream = response.GetResponseStream(); using (BinaryReader br = new BinaryReader(receiveStream)) { b = br.ReadBytes(500000); br.Close(); } } } return b; }
Initial URL
Initial Description
This snippet pulls down an image from a URL into a byte(). From there you can re-size or save. Don't forget the necessary try - catch.
Initial Title
Pull Image into Byte Array from a URL
Initial Tags
url, image
Initial Language
C#