上传图片并修改其大小(C#)

类别:.NET开发 点击:0 评论:0 推荐:
上传图片并修改其大小
//thefile是一个File Field HTML 控件
thefile.PostedFile.SaveAs(System.Web.HttpContext.Current.Server.MapPath("temp.png"));
MemoryStream MemStream=new MemoryStream();
System.Drawing.Image imgOutput =System.Drawing.Bitmap.FromFile(System.Web.HttpContext.Current.Server.MapPath("temp.png"));
//修改成80×80大小
System.Drawing.Image imgOutput2=imgOutput.GetThumbnailImage(80,80,null,IntPtr.Zero);
imgOutput2.Save(System.Web.HttpContext.Current.Server.MapPath("image.png"), ImageFormat.Png);
Response.Write(thefile.PostedFile.FileName);
Response.Write("Len:"+MemStream.Length.ToString());
imgOutput.Dispose();
imgOutput2.Dispose();
Response.Write("上传成功!");
Response.Write(System.Web.HttpContext.Current.Server.MapPath("image.png"));
----------------------------------------- 飘飘何所似?天地一沙鸥。

本文地址:http://com.8s8s.com/it/it42184.htm