码迷,mamicode.com
首页 > 其他好文 > 详细

C#生成高清缩略图 (装在自OPEN经验库)

时间:2014-05-22 15:55:33      阅读:216      评论:0      收藏:0      [点我收藏+]

标签:des   style   blog   class   c   code   

来源 http://www.open-open.com/lib/view/open1389943861320.html

 

代码如下实现图片的高清缩略图

bubuko.com,布布扣
/// <summary>  
   /// 为图片生成缩略图    
   /// </summary>  
   /// <param name="phyPath">原图片的路径</param>  
   /// <param name="width">缩略图宽</param>  
   /// <param name="height">缩略图高</param>  
   /// <returns></returns>  
   public System.Drawing.Image GetThumbnail(System.Drawing.Image image, int width, int height)  
   {  
       Bitmap bmp = new Bitmap(width, height);  
       //从Bitmap创建一个System.Drawing.Graphics  
       System.Drawing.Graphics gr = System.Drawing.Graphics.FromImage(bmp);  
       //设置   
       gr.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;  
       //下面这个也设成高质量  
       gr.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality;  
       //下面这个设成High  
       gr.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;  
       //把原始图像绘制成上面所设置宽高的缩小图  
       System.Drawing.Rectangle rectDestination = new System.Drawing.Rectangle(0, 0, width, height);  
   
       gr.DrawImage(image, rectDestination, 0, 0, image.Width, image.Height, GraphicsUnit.Pixel);  
       return bmp;  
   }  
bubuko.com,布布扣

 

C#生成高清缩略图 (装在自OPEN经验库),布布扣,bubuko.com

C#生成高清缩略图 (装在自OPEN经验库)

标签:des   style   blog   class   c   code   

原文地址:http://www.cnblogs.com/qishiguilai/p/3743992.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!