编程语言

img delphiseabird

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

发表于2004/12/30 14:40:00  829人阅读

//上传图片并修改其大小 
//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"));
-----------------------------------------
飘飘何所似?天地一沙鸥。
阅读全文
0 0

相关文章推荐

img
取 消
img