(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/