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

推荐订阅源

S
Secure Thoughts
P
Privacy International News Feed
T
Tenable Blog
L
Lohrmann on Cybersecurity
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
T
Threat Research - Cisco Blogs
S
Securelist
C
CXSECURITY Database RSS Feed - CXSecurity.com
Cisco Talos Blog
Cisco Talos Blog
T
The Exploit Database - CXSecurity.com
S
Schneier on Security
P
Privacy & Cybersecurity Law Blog
Vercel News
Vercel News
Cyberwarzone
Cyberwarzone
月光博客
月光博客
T
The Blog of Author Tim Ferriss
Scott Helme
Scott Helme
爱范儿
爱范儿
Stack Overflow Blog
Stack Overflow Blog
C
Cisco Blogs
aimingoo的专栏
aimingoo的专栏
博客园 - 司徒正美
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
P
Proofpoint News Feed
A
Arctic Wolf
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
L
LangChain Blog
C
Cyber Attacks, Cyber Crime and Cyber Security
阮一峰的网络日志
阮一峰的网络日志
Simon Willison's Weblog
Simon Willison's Weblog
T
Tor Project blog
Security Latest
Security Latest
Blog — PlanetScale
Blog — PlanetScale
G
GRAHAM CLULEY
V
Vulnerabilities – Threatpost
博客园 - 三生石上(FineUI控件)
I
InfoQ
Spread Privacy
Spread Privacy
B
Blog RSS Feed
Microsoft Azure Blog
Microsoft Azure Blog
S
SegmentFault 最新的问题
云风的 BLOG
云风的 BLOG
Last Week in AI
Last Week in AI
MongoDB | Blog
MongoDB | Blog
C
CERT Recently Published Vulnerability Notes
A
About on SuperTechFans
博客园_首页
Engineering at Meta
Engineering at Meta
Project Zero
Project Zero
Latest news
Latest news

博客园 - 无极.net

.NET正则表达式使用高级技巧之工作特点 .NET正则表达式使用高级技巧之反向引用 - 无极.net - 博客园 .NET正则表达式使用高级技巧之组的概念 - 无极.net - 博客园 .NET正则表达式使用高级技巧之替换类 C#中利用正则表达式实现字符串搜索 字符串长度,同时考虑二个英文=一个中文 - 无极.net - 博客园 FLASH图片新闻代码 - 无极.net - 博客园 正则表达式30分钟入门教程 v2.1 两个固定宽度的DIV,不换行 - 无极.net - 博客园 UrlReWriter 使用经验小结 如何在JS里取得两个数相除的整数和余数,那么如何判断一个数是整数呢? 向上滚动 flash从asp中调用变量 菜单 ASP.NET AJAX(开发代号Atlas)重要参考资源大收集 索引[]在字符串中的用法 div 相对于浮动层定位,不占位 储存过程里设置了OUTPUT,取值 SQL 声明变量 declare
c# 添加图片水印,可以指定水印位置+生成缩略图 - 无极.net - 博客园
无极.net · 2007-04-25 · via 博客园 - 无极.net


 1
 2        /// <summary>
 3        /// 生成缩略图
 4        /// </summary>
 5        /// <param name="oldpath">原图片地址</param>
 6        /// <param name="newpath">新图片地址</param>
 7        /// <param name="tWidth">缩略图的宽</param>
 8        /// <param name="tHeight">缩略图的高</param>

 9        private void  GreateMiniImage(string oldpath,string newpath,int tWidth, int tHeight)
10        {
11        
12            try
13            {
14
15                System.Drawing.Image image = System.Drawing.Image.FromFile(oldpath);
16                double bl=1d;
17                if((image.Width<=image.Height)&&(tWidth>=tHeight))
18                {
19                    bl=Convert.ToDouble(image.Height)/Convert.ToDouble(tHeight);
20                }

21                else if((image.Width>image.Height)&&(tWidth<tHeight))
22                {
23                    bl=Convert.ToDouble(image.Width)/Convert.ToDouble(tWidth);
24            
25                }

26                else
27            
28                    if((image.Width<=image.Height)&&(tWidth<=tHeight))
29                {
30                    if(image.Height/tHeight>=image.Width/tWidth)
31                    {
32                        bl=Convert.ToDouble(image.Width)/Convert.ToDouble(tWidth);
33                    
34                    }

35                    else
36                    {
37                        bl=Convert.ToDouble(image.Height)/Convert.ToDouble(tHeight);
38                    }

39                }

40                else
41                {
42                    if(image.Height/tHeight>=image.Width/tWidth)
43                    {
44                        bl=Convert.ToDouble(image.Height)/Convert.ToDouble(tHeight);
45                    
46                    }

47                    else
48                    {
49                        bl=Convert.ToDouble(image.Width)/Convert.ToDouble(tWidth);
50                    
51                    }

52            
53                }

54
55            
56                Bitmap b = new Bitmap(image ,Convert.ToInt32(image.Width/bl), Convert.ToInt32(image.Height/bl));
57
58                b.Save(newpath);
59                b.Dispose();
60                image.Dispose();
61                
62
63            }

64            catch
65            {
66            
67                
68            }

69            
70        }