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

推荐订阅源

S
SegmentFault 最新的问题
V
V2EX
L
LangChain Blog
WordPress大学
WordPress大学
大猫的无限游戏
大猫的无限游戏
T
The Blog of Author Tim Ferriss
Recorded Future
Recorded Future
月光博客
月光博客
Y
Y Combinator Blog
Stack Overflow Blog
Stack Overflow Blog
美团技术团队
博客园 - 【当耐特】
The Cloudflare Blog
罗磊的独立博客
GbyAI
GbyAI
A
About on SuperTechFans
腾讯CDC
宝玉的分享
宝玉的分享
I
InfoQ
V
Visual Studio Blog
Forbes - Security
Forbes - Security
P
Proofpoint News Feed
T
Troy Hunt's Blog
NISL@THU
NISL@THU
Webroot Blog
Webroot Blog
T
Threatpost
博客园 - 三生石上(FineUI控件)
S
Securelist
H
Help Net Security
小众软件
小众软件
L
Lohrmann on Cybersecurity
Cyberwarzone
Cyberwarzone
T
The Exploit Database - CXSecurity.com
量子位
博客园_首页
Scott Helme
Scott Helme
酷 壳 – CoolShell
酷 壳 – CoolShell
雷峰网
雷峰网
J
Java Code Geeks
G
GRAHAM CLULEY
T
Tor Project blog
The GitHub Blog
The GitHub Blog
Cloudbric
Cloudbric
IT之家
IT之家
阮一峰的网络日志
阮一峰的网络日志
Hacker News - Newest:
Hacker News - Newest: "LLM"
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
Schneier on Security
Schneier on Security
V
Vulnerabilities – Threatpost
Jina AI
Jina AI

博客园 - 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{}
 }