Image 获取缩略图

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);
  }
}

上一篇:Android中关于在onDrow或者onMeasure中创建对象提示Avoid object allocations during draw/layout operations (preallocate and reuse instead) 问题


下一篇:Nginx日志按天切割及日志基本配置说明