private void GetThumbNail(string strFileName, int iWidth, int
iheight)
{
try
{
System.Drawing.Image oImg;
oImg = System.Drawing.Image.FromFile(strFileName);
oImg = oImg.GetThumbnailImage(iWidth, iheight, null, IntPtr.Zero); //GetThumbnailImage方法是返回此Image对象的缩略图
string strGuid = System.Guid.NewGuid().ToString().ToUpper(); //初始化 Guid 类的新实例
string strFileExt = strFileName.Substring(strFileName.LastIndexOf(".")); //得到图片的后缀
System.IO.MemoryStream MemStream = new System.IO.MemoryStream(); //创建其支持存储区为内存的流
oImg.Save(MemStream, System.Drawing.Imaging.ImageFormat.Bmp);
MemStream.WriteTo(Response.OutputStream); //WriteTo方法是将此内存流的整个内容写入另一个流中
}
catch (Exception ex)
{
Response.Write(ex.Message);
}
}