惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

H
Help Net Security
博客园 - Franky
GbyAI
GbyAI
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
爱范儿
爱范儿
IT之家
IT之家
酷 壳 – CoolShell
酷 壳 – CoolShell
aimingoo的专栏
aimingoo的专栏
博客园_首页
MongoDB | Blog
MongoDB | Blog
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
Recent Announcements
Recent Announcements
Scott Helme
Scott Helme
有赞技术团队
有赞技术团队
M
MIT News - Artificial intelligence
C
CERT Recently Published Vulnerability Notes
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
Jina AI
Jina AI
F
Fortinet All Blogs
N
Netflix TechBlog - Medium
L
LangChain Blog
L
LINUX DO - 最新话题
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
H
Hacker News: Front Page
MyScale Blog
MyScale Blog
P
Palo Alto Networks Blog
G
Google Developers Blog
Google DeepMind News
Google DeepMind News
AI
AI
T
Troy Hunt's Blog
Microsoft Azure Blog
Microsoft Azure Blog
阮一峰的网络日志
阮一峰的网络日志
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Vercel News
Vercel News
Microsoft Security Blog
Microsoft Security Blog
罗磊的独立博客
S
Secure Thoughts
大猫的无限游戏
大猫的无限游戏
博客园 - 叶小钗
人人都是产品经理
人人都是产品经理
Blog — PlanetScale
Blog — PlanetScale
博客园 - 司徒正美
Apple Machine Learning Research
Apple Machine Learning Research
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
博客园 - 三生石上(FineUI控件)
S
Security @ Cisco Blogs
Cloudbric
Cloudbric
E
Exploit-DB.com RSS Feed
Attack and Defense Labs
Attack and Defense Labs

博客园 - Rickel

在webView 中使用JS 调用 Android / IOS的函数 Function 数据库镜像的配置 查看SQL Server中某数据库下每个表占用的空间大小 about WBS sql server 2005 压缩实例下所有数据库文件及日志文件 语句 TFS服务器及服务帐号迁域的处理 [西安招聘] 微软西安分公司 招聘.NET软件工程师,MOSS开发工程师 SQL清除数据库日志方法 JavaScript 中的Key 事件区别 ASP.NET URL Rewrite. URL重写 Apache Error:(OS 10048)Only one usage of each socket address is normally permitted. 页面响应自定义控件的事件 推荐大家看 《亵渎》 断字处理 break-word I'm Back 部署带Crystal Reports的Web应用程序 用C#读取Excel文件:从指定单元格开始向右向下读取数据 Well-formed AssemblyInfo.cs 毕业一周年纪念
生成高品质的缩略图
Rickel · 2007-02-04 · via 博客园 - Rickel

转自:http://hi.baidu.com/zhaoyf/blog/item/06d6b812175371cec2fd7812.html

高品质,就是指定Graphic的

InterpolationMode属性为HighQualityBicubic

public static void myGetThumbnailImage(string SourceFile, string strSavePathFile, int ThumbWidth, int ThumbHeight, string BgColor) 
    { 
        System.Drawing.Image oImg 
= System.Drawing.Image.FromFile(SourceFile); 
        
//小图 
        int intwidth, intheight; 
        
if (oImg.Width > oImg.Height) 
        { 
            
if (oImg.Width > ThumbWidth) 
            { 
                intwidth 
= ThumbWidth; 
                intheight 
= (oImg.Height * ThumbWidth) / oImg.Width; 
            } 
            
else 
            { 
                intwidth 
= oImg.Width; 
                intheight 
= oImg.Height; 
            } 
        } 
        
else 
        { 
            
if (oImg.Height > ThumbHeight) 
            { 
                intwidth 
= (oImg.Width * ThumbHeight) / oImg.Height; 
                intheight 
= ThumbHeight; 
            } 
            
else 
            { 
                intwidth 
= oImg.Width; 
                intheight 
= oImg.Height; 
            } 
        } 
        
//构造一个指定宽高的Bitmap 
        Bitmap bitmay = new Bitmap(intwidth, intheight); 
        Graphics g 
= Graphics.FromImage(bitmay); 
        Color myColor; 
        
if (BgColor == null
            myColor 
= Color.FromName("white"); 
        
else 
            myColor 
= Color.FromName(BgColor); 
        
//用指定的颜色填充Bitmap 
        g.Clear(myColor); 
        g.InterpolationMode 
= InterpolationMode.HighQualityBicubic;  
        
//开始画图 
        g.DrawImage(oImg, new Rectangle(00, intwidth, intheight), new Rectangle(00, oImg.Width, oImg.Height), GraphicsUnit.Pixel); 
        bitmay.Save(strSavePathFile, System.Drawing.Imaging.ImageFormat.Jpeg); 
        g.Dispose(); 
        bitmay.Dispose(); 
        oImg.Dispose(); 
        
//删除源图 
        try 
        { 
            File.Delete(SourceFile); 
        } 
        
catch 
        { 
        } 
    }