zoukankan      html  css  js  c++  java
  • 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);
      }
    }

  • 相关阅读:
    JavaScript 面向对象
    javascript中this的指向
    销售
    Java垃圾回收机制
    判断浏览器是否缩放
    pattern space and hold space of sed
    语言基础
    Python中PyQuery库的使用总结
    多个计数器在Vuex中的状态
    Sklearn
  • 原文地址:https://www.cnblogs.com/qiliping/p/2615835.html
Copyright © 2011-2022 走看看