C # Image Binary storage in winform-resize-Display

Source: Internet
Author: User

(1)convert the.jpg file to a binary array and put it in the arrbyte array.

 
Filestream FS = new filestream (@ "F: \ a.jpg", filemode. open, fileaccess. read); byte [] arrbyte = new byte [FS. length]; FS. read (arrbyte, 0, arrbyte. length); FS. close ();

(2) Change the image size. Use the bitmap class to change the image size to 40-50 in width and put it in a binary array.

 
Image IMG = new Bitmap (image. fromstream (New memorystream (byte []) arrbyte), 40, 50); // image img1 = new Bitmap (image. fromfile (@ "F: \ a.jpg"),); memorystream MS = new memorystream (); IMG. save (MS, system. drawing. imaging. imageformat. JPEG); byte [] arrbyte1 = Ms. getbuffer ();

(3) convert the binary array arrbyte into an image;

 
Image readimg = image. fromstream (New memorystream (byte []) arrbyte); picturebox1.image = readimg;

From: http://xuehaiboisme.blog.163.com/blog/static/8414282920105255026495/

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.