Image conversion binary stream-binary stream conversion image storage (applicable to winform and wince)

Source: Internet
Author: User

The Code is as follows:

Private void button1_click (Object sender, eventargs e) {Bitmap bitmap = new Bitmap (path. getdirectoryname (assembly. getexecutingassembly (). getname (). codebase. tostring () + "\ checktable \ select standard .jpg"); // convert the image to a binary stream memorystream MS = NULL; byte [] byteimage; try {MS = new memorystream (); bitmap. save (MS, imageformat. JPEG); byteimage = new byte [Ms. length]; byteimage = Ms. toarray (); // send byteimage} catch (argumentnullexception ex) {Throw ex;} finally {Ms. close () ;}// the binary stream is converted to the image memorystream = NULL; try {stream = new memorystream (byteimage ); // byteimage is the received binary array image bitmapnew = (image) New Bitmap (Stream); bitmapnew. save (path. getdirectoryname (assembly. getexecutingassembly (). getname (). codebase. tostring () + "\ checktable \ xin.jpg", imageformat. JPEG);} catch (argumentnullexception ex) {Throw ex;} catch (argumentexception ex) {Throw ex;} finally {stream. close ();}}

Reference: click ....

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.