<% @ Page language = "c #" responseEncoding = "gb2312" debug = "true"%> <% @ import namespace = "system"%> <% @ import namespace = "system.io"%> <% @ import namespace = "System.drawing"%> <% @ import namespace = "system.drawing.imaging"%>
void Page_Load (Object sender, EventArgs e) {if {ImgPreview.Visible = false (Page.IsPostBack!);}} void GetThumbnailImage (int width, int height, string strInfo, int left, int right) {string file = "Uploads /" uploadFile.PostedFile.FileName.Substring(uploadFile.PostedFile.FileName.LastIndexOf('//') 1);string newfile = "Uploads /" uploadFile.PostedFile.FileName.Substring (uploadFile.PostedFile.FileName. LastIndexOf ( '//') 1) "jpg."; string strAdd = strInfo; System.Drawing.Image oldimage = System.Drawing.Image.FromFile (Server.MapPath (file)); System.Drawing.Image thumbnailImage = oldimage.GetThumbnailImage (width, height, new System.Drawing.Image.GetThumbnailImageAbort (ThumbnailCallback), IntPtr.Zero); Response.Clear (); Bitmap output = new Bitmap (thumbnailImage); Graphics g = Graphics.FromImage (output) G. DrawString (Stradd, New Font ("Courier New", 14), New Solidbrush (Color.Red), Left, Right; Output.Save (Server.MAppath (NewFile), System.drawing.Imaging.ImageFormat. JPEG); response.contentType = "image / gif"; imgpreview.visible = true; IMGPR Eview.imageurl = newfile;} Bool thumbnailcallback () {Return True;}
void Button_Click (object sender, EventArgs e) {int width, height, left, right; string strAddInfo = txtAddInfo.Text; width = Int32.Parse (txtWidth.Text); height = Int32.Parse (txtHeight.Text); left = INT32.PARSE (TXTLEFT.TEXT); Right = Int32.Parse (TXTRIGHT.TEXT); if (! (UPLOADFILE.POSTEDFILE.CONTENTLENGTH> 0)) {LBLERRINFO.TEXT = "No Selection File";} else {
String path = server.mappath ("./ Uploads /" UPLOADFILE.POSTEDFILE.FILENAME.SUBSTED (UPLOADFILE.POSTEDFILE.FILENAME.LASTINDEXOF ('//') 1); if (file.exists (path)) { LBLERRINFO.TEXT = "There is already the same name file";} else {UPLOADFILE.POSTEDFILE.SAVEAS (PATH); GetthumbnailImage (width, height, straddinfo, left, right);}}} script>
< / head>