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

推荐订阅源

C
CXSECURITY Database RSS Feed - CXSecurity.com
Stack Overflow Blog
Stack Overflow Blog
月光博客
月光博客
T
Threat Research - Cisco Blogs
小众软件
小众软件
有赞技术团队
有赞技术团队
酷 壳 – CoolShell
酷 壳 – CoolShell
Apple Machine Learning Research
Apple Machine Learning Research
C
Cyber Attacks, Cyber Crime and Cyber Security
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
T
Tailwind CSS Blog
Cisco Talos Blog
Cisco Talos Blog
V
V2EX
博客园 - 【当耐特】
C
Cybersecurity and Infrastructure Security Agency CISA
Hugging Face - Blog
Hugging Face - Blog
The Cloudflare Blog
The Last Watchdog
The Last Watchdog
Simon Willison's Weblog
Simon Willison's Weblog
T
Threatpost
S
Secure Thoughts
O
OpenAI News
P
Proofpoint News Feed
S
SegmentFault 最新的问题
Forbes - Security
Forbes - Security
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
Application and Cybersecurity Blog
Application and Cybersecurity Blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Last Week in AI
Last Week in AI
宝玉的分享
宝玉的分享
Scott Helme
Scott Helme
T
Tenable Blog
A
Arctic Wolf
L
LINUX DO - 热门话题
爱范儿
爱范儿
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
www.infosecurity-magazine.com
www.infosecurity-magazine.com
V
Visual Studio Blog
Hacker News: Ask HN
Hacker News: Ask HN
Hacker News - Newest:
Hacker News - Newest: "LLM"
腾讯CDC
博客园 - Franky
WordPress大学
WordPress大学
Know Your Adversary
Know Your Adversary
博客园_首页
雷峰网
雷峰网
IT之家
IT之家
PCI Perspectives
PCI Perspectives
L
LINUX DO - 最新话题
H
Heimdal Security Blog

博客园 - sh37

Newtonsoft中的几个妙用 Mvc中ViewData与TempData的区别 Silverlight中利用ListBox特性实现单选按钮组RadioButtonList和复选按钮组CheckBoxList的功能 SilverLight中Page也可使用泛型基类 cookie操作 - sh37 - 博客园 C# 利用net 命令获取域用户列表 - sh37 利用MessageQueue收发消息 - sh37 - 博客园 C# xmlhttp - sh37 - 博客园 使用ASP获得AD帐号 “域\用户名” - sh37 - 博客园 使用ASP.NET获得AD帐号 - sh37 - 博客园 根據xml文檔數據 給DataTable增加行 JS获取剪贴板内容的代码 - sh37 - 博客园 分页时使当前页码变色 自動生成帶文字的圖片 常用pl/sql vb.net後台抓取網頁內容 ServerVariables集合内容列表 如何动态创建一个按纽 并给这个按纽绑上一个Onclick事件 17种常用正则表达式
C#生成缩略图
sh37 · 2006-08-11 · via 博客园 - sh37

//注意引入 using System.Drawing.Imaging;
public bool ThumbnailCallback()
  {
   return false;
  } 
////oldfile原图地址,  newfile新图地址
  private void ShowThumbnail(string oldfile,string newfile)
  {  
   System.Drawing.Image image =System.Drawing.Image.FromFile(oldfile);
       //获取原图高度和宽度
         int oldh = image.Height;
         int oldw = image.Width;
         int neww,newh;
        neww=100;newh=100;   //直接设定新图的高宽,,等比缩放代码略,
     try
     {
           System.Drawing.Image.GetThumbnailImageAbort callb=new System.Drawing.Image.GetThumbnailImageAbort(ThumbnailCallback);
          System.Drawing.Image bt=new System.Drawing.Bitmap(neww,newh);
          System.Drawing.Graphics gr=System.Drawing.Graphics.FromImage(bt);
           gr.Clear(Color.White);
           gr.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
           gr.DrawImage(image, new Rectangle(0,0,neww,newh), 0, 0, oldw,oldh, GraphicsUnit.Pixel);
          switch(oldfile.Substring(oldfile.Length-3).ToUpper())
          {
                case "JPG":
                bt.Save(newfile,ImageFormat.Jpeg);
                break;
                case "GIF":
                 bt.Save(newfile,ImageFormat.Gif);
                 break;
                 case "PNG":
                 bt.Save(newfile,ImageFormat.Png);
                 break;
                 default:
                 bt.Save(newfile,ImageFormat.Jpeg);
                  break;
            } 
            gr.Dispose();
            bt.Dispose();
            image.Dispose();
     }
   catch{}
 }