Using system; <br/> using system. collections. generic; <br/> using system. componentmodel; <br/> using system. data; <br/> using system. drawing; <br/> using system. text; <br/> using system. windows. forms; </P> <p> namespace ex13_01 <br/>{< br/> Public partial class form1: Form <br/>{< br/> Public form1 () <br/>{< br/> initializecomponent (); <br/>}< br/> bitmap mybitmap; <br/> private void button#click (Object sender, eventargs E) <br/>{< br/> try <br/>{< br/> This. refresh (); <br/> // open the image file <br/> openfiledialog = new openfiledialog (); <br/> openfiledialog. filter = "image file (JPEG, GIF) | *. JPG ;*. JPEG ;*. GIF; | JPEG image file (*. JPG ;*. JPEG) | *. JPG ;*. JPEG | GIF image file (*. GIF) | *. GIF "; <br/> If (openfiledialog. showdialog () = dialogresult. OK) <br/>{< br/> // obtain the original size image <br/> mybitmap = new Bitmap (openfiledialog. filename); <br/>}< br/> int width = 0, Height = 0; <br/> If (mybitmap. width> mybitmap. height) <br/>{< br/> width = 50; <br/> Height = convert. toint32 (convert. tosingle (mybitmap. height)/convert. tosingle (mybitmap. width) * 50; <br/>}< br/> else <br/>{< br/> Height = 50; <br/> width = convert. toint32 (convert. tosingle (mybitmap. width)/convert. tosingle (mybitmap. height) * 50; <br/>}< br/> image thumbnail = mybitmap. getthumbnailimage (width, height, null, intptr. zero); <br/> graphics G = This. creategraphics (); <br/> G. drawimage (thumbnail, 10, 10); <br/> G. drawstring (openfiledialog. filename, new font ("", 10f), brushes. black, 10, height + 20); <br/> G. dispose (); <br/>}< br/> catch (exception ex) <br/>{< br/> MessageBox. show (ex. message, "prompt message"); <br/>}</P> <p> private void form1_load (Object sender, eventargs E) <br/>{< br/>}< br/>}