如何实现将用户上传的文件生成缩略图! - 中国WEB开发者网络 (http://www.webasp.net) -- 技术教程 (http://www.webasp.net/article/) --- 如何实现将用户上传的文件生成缩略图! (http://www.webasp.net/article/14/13762.htm) |
| -- 作者:未知 -- 发布日期: 2004-10-12 |
| 具体给个例子就清楚啦。。
如下: System.Web.HttpPostedFile UpFile = UpMhtFile.PostedFile; System.IO.Stream StreamObject = UpFile.InputStream; System.IO.FileStream myStream = new System.IO.FileStream(UpFile.FileName,System.IO.FileMode.Open,System.IO.FileAccess.Read); System.Drawing.Image.GetThumbnailImageAbort myCallback = new System.Drawing.Image.GetThumbnailImageAbort(ThumbnailCallback); System.Drawing.Image img1 = System.Drawing.Image.FromStream(StreamObject); System.Drawing.Image timg = img1.GetThumbnailImage(100,100,myCallback,System.IntPtr.Zero); timg.Save(Response.OutputStream,System.Drawing.Imaging.ImageFormat.Jpeg); 上例中UpMhtFile是一个upfile WebControl,上述情况将上传的图片转换成流,然后生成缩略图后直接保存在输出流中,一般用于从数据库中读出流后生成图片浏览。 |
| webasp.net |