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

推荐订阅源

I
Intezer
Google DeepMind News
Google DeepMind News
有赞技术团队
有赞技术团队
博客园 - Franky
Jina AI
Jina AI
博客园_首页
大猫的无限游戏
大猫的无限游戏
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
Engineering at Meta
Engineering at Meta
B
Blog
A
About on SuperTechFans
J
Java Code Geeks
WordPress大学
WordPress大学
GbyAI
GbyAI
N
News | PayPal Newsroom
C
Cybersecurity and Infrastructure Security Agency CISA
博客园 - 聂微东
Stack Overflow Blog
Stack Overflow Blog
T
The Exploit Database - CXSecurity.com
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
N
Netflix TechBlog - Medium
Last Week in AI
Last Week in AI
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
P
Palo Alto Networks Blog
U
Unit 42
Vercel News
Vercel News
Microsoft Azure Blog
Microsoft Azure Blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Know Your Adversary
Know Your Adversary
博客园 - 三生石上(FineUI控件)
AWS News Blog
AWS News Blog
Latest news
Latest news
V
V2EX
Y
Y Combinator Blog
Scott Helme
Scott Helme
博客园 - 叶小钗
美团技术团队
A
Arctic Wolf
S
Secure Thoughts
H
Help Net Security
L
LangChain Blog
博客园 - 司徒正美
V2EX - 技术
V2EX - 技术
P
Proofpoint News Feed
M
MIT News - Artificial intelligence
I
InfoQ
Cyberwarzone
Cyberwarzone
S
SegmentFault 最新的问题
Hacker News - Newest:
Hacker News - Newest: "LLM"

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