Convert a network image into a byte array:
Public byte [] sg_servicesfunctiongetpicture (string imgurl) <br/>{< br/> try <br/>{< br/> memorystream M = new memorystream (); <br/> webrequest wR = webrequest. create (imgurl); <br/> webresponse res = Wr. getresponse (); <br/> bitmap BP = new Bitmap (res. getresponsestream (); <br/> bp. save (M, system. drawing. imaging. imageformat. GIF); <br/> bp. dispose (); <br/> M. dispose (); <br/> return M. getbuffer (); <br/>}< br/> catch (exception) <br/>{< br/> return system. text. encoding. default. getbytes ("the image address does not exist"); <br/>}< br/>}
After obtaining the byte array, parse it into an image and display it:
String base64 = system. convert. tobase64string (sg_servicesfunctiongetpicture (imgurl); <br/> memorystream = new system. io. memorystream (system. convert. frombase64string (base64); <br/> IMG = new Bitmap (memorystream); <br/> IMG. save (memorystream, system. drawing. imaging. imageformat. GIF); <br/> response. clearcontent (); <br/> response. contenttype = "image/GIF"; <br/> response. binarywrite (memorystream. toarray (); <br/> response. end ();