生成缩略图是一个十分常用功能,找到了一个方法,重写部分代码,实用又好用,.net又一个生成缩略图的方法,不变形

 /// <summary>
/// 为图片生成缩略图 by 何问起
/// </summary>
/// <param name="phyPath">原图片的路径</param>
/// <param name="width">缩略图宽</param>
/// <param name="height">缩略图高</param>
/// <returns></returns>
public System.Drawing.Image GetHvtThumbnail(System.Drawing.Image image, int width, int height)
{
//代码是从开源项目HoverTreeCMS中获取的
//更多信息请参考:http://hovertree.com/menu/hovertreecms/
Bitmap m_hovertreeBmp = new Bitmap(width, height);
//从Bitmap创建一个System.Drawing.Graphics
Graphics m_HvtGr = Graphics.FromImage(m_hovertreeBmp);
//设置
m_HvtGr.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
//下面这个也设成高质量
m_HvtGr.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality;
//下面这个设成High
m_HvtGr.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
//把原始图像绘制成上面所设置宽高的缩小图
Rectangle rectDestination = new Rectangle(, , width, height); int m_width, m_height;
if (image.Width * height > image.Height * width)
{
m_height = image.Height;
m_width = (image.Height * width) / height;
}
else
{
m_width = image.Width;
m_height = (image.Width * height) / width;
} m_HvtGr.DrawImage(image, rectDestination, , , m_width, m_height, GraphicsUnit.Pixel); return m_hovertreeBmp;
}

.net又一个生成缩略图的方法,不变形,非常好用的更多相关文章

  1. .net又一个生成缩略图的方法,不变形

    生成缩略图是一个十分常用功能,找到了一个方法,重写部分代码,实用又好用,.net又一个生成缩略图的方法,不变形 /// <summary> /// 为图片生成缩略图 by 何问起 /// ...

  2. C#生成缩略图的方法

    1.需要添加应用System.Drawing.dll 2.命名空间 using System.IO; using System.Drawing; using System.Drawing.Imagin ...

  3. ThinkPHP 5 文件上传及指定宽高生成缩略图公共方法

    这个是非常常用的案例,ThinkPHP 5 文件上传及指定宽高生成缩略图公共方法/** * 单文件上传 * name:表单上传文件的名字 * ext: 文件允许的后缀,字符串形式 * path:文件保 ...

  4. PS如何批量生成缩略图(方法可以通用其他重复劳动)

    原图 缩略 进入正题,学生时代玩过脚本精灵的应该一点就通 原理就是:录制一系列动作,然后生成脚本,并执行(经常PS水印代码的一个可以用程序实现,一个就可以用PS脚本) 新建一个组 新建一个动作 进行你 ...

  5. C#生成缩略图代码

    /**//// <summary>         /// 生成缩略图         /// </summary>         /// <param name=&q ...

  6. ThinkPHP5.0图片上传生成缩略图实例代码

    很多朋友遇到这样一个问题,图片上传生成缩略图,很多人在本机(win)测试成功,上传到linux 服务器后错误. 我也遇到同样的问题.网上一查,有无数的人说是服务器临时文件目录权限问题. 几经思考后,发 ...

  7. PHP生成缩略图的一个方法类(转)

    //使用如下类就可以生成图片缩略图 class resizeimage { //图片类型 var $type; //实际宽度 var $width; //实际高度 var $height; //改变后 ...

  8. C#生成高清缩略图的方法

    /// <summary> /// 为图片生成缩略图 /// </summary> /// <param name="phyPath">原图片的 ...

  9. ASP组件AspJpeg(加水印)生成缩略图等使用方法

    ASP组件AspJpeg(加水印)生成缩略图等使用方法 作者: 字体:[增加 减小] 类型:转载 时间:2012-12-17我要评论 ASPJPEG是一款功能相当强大的图象处理组件,用它可以轻松地做出 ...

随机推荐

  1. Hashtable,HashMap实现原理

    http://blog.csdn.net/czh0766/article/details/5260360 昨天看了算法导论对散列表的介绍,今天看了一下Hashtable, HashMap这两个类的源代 ...

  2. MySQL协议简单分析

     tcpdump -i eth0 -s0  -l -w - port 3306|strings|grep -i -E 'select|update|insert|delete|set' 

  3. 5种php加密工具zendGuard、ionCube、SourceCop、SourceGuardian、phpShield

    PHP做桌面应用的想法: 除去icudt55.dll,PHP7用7ZIP压缩后不足7MB,而PHP自带了SQLite和CLI HTTP Server,用户打开浏览器就能访问PHP开发的桌面应用.如果源 ...

  4. UI设计师的 Android 备忘录

    Images and themes Nine-patch Colors Holo themes Naming conventions Naming conventions for drawables ...

  5. Spring messageSource

    Spring中可以使用两个类加载资源文件: org.springframework.context.support.ReloadableResourceBundleMessageSource 和 or ...

  6. Java多线程(四)之ConcurrentSkipListMap深入分析

    一.前言 concurrentHashMap与ConcurrentSkipListMap性能测试 在4线程1.6万数据的条件下,ConcurrentHashMap 存取速度是ConcurrentSki ...

  7. HashMap循环遍历方式及其性能对比

    主要介绍HashMap的四种循环遍历方式,各种方式的性能测试对比,根据HashMap的源码实现分析性能结果,总结结论.   1. Map的四种遍历方式 下面只是简单介绍各种遍历示例(以HashMap为 ...

  8. CnPack for delphi xe5

    CnPack Team is made up of Chinese Programmers and Delphi / C++ Builder fans across the Internet. Our ...

  9. [XenServer] XenServer修改IP 以及 root密码

     A.修改IP以及DNS 1. root用户登录console 2.输入命令获得UUID xe pif-list 3.利用UUID查看之前的IP,注意替换下面的1111111111 xe pif-pa ...

  10. 国内maven镜像

    <mirrors> <mirror> <id>alimaven</id> <name>aliyun maven</name> & ...