C # returns the byte stream of the image []
# Region returns the byte stream of the image byte [] ///// Byte [] ///////////
Public static byte [] getImageByte (string imagePath, WebClient webClient) {byte [] imgByte = null; try {// MessageBox. show ("getImageByte"); // Stopwatch stopwatch = new Stopwatch (); // stopwatch. start (); // DateTime dateStart = DateTime. now; if (PubFunc. urlDiscern (imagePath) {Bitmap bt = new Bitmap (webClient. openRead (imagePath); imgByte = PubFunc. imgToByte (bt);} else {using (FileStream files = new FileStream (imagePath, FileMode. open) {imgByte = new byte [files. length]; files. read (imgByte, 0, imgByte. length); files. close () ;}// stopwatch. stop (); // MessageBox. show (DateTime. now-dateStart ). totalMilliseconds. toString ();} catch (Exception ee) {MessageBox. show (ee. toString ();} return imgByte;} # endregion
# Region image conversion to word throttling ////// Convert the image into word throttling //////Image object to be converted ///
Byte stream returned after conversion
Public static byte [] ImgToByte (Image img) {try {using (MemoryStream MS = new MemoryStream () {byte [] imagedata = null; img. save (MS, System. drawing. imaging. imageFormat. jpeg); imagedata = ms. getBuffer (); return imagedata ;}} catch (Exception ee) {MessageBox. show (ee. toString (); return null ;}# endregion