如何实现将用户上传的文件生成缩略图!
发表于:2007-06-30来源:作者:点击数:
标签:
具体给个例子就清楚啦。。 如下: 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,Sy
具体给个例子就清楚啦。。
如下:
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.FileA
clearcase/" target="_blank" >ccess.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,上述情况将上传的图片转换成流,然后生成缩略图后直接保存在输出流中,一般用于从
数据库中读出流后生成图片浏览。
原文转自:http://www.ltesting.net