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

推荐订阅源

Recent Commits to openclaw:main
Recent Commits to openclaw:main
GbyAI
GbyAI
Y
Y Combinator Blog
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
aimingoo的专栏
aimingoo的专栏
H
Hackread – Cybersecurity News, Data Breaches, AI and More
云风的 BLOG
云风的 BLOG
博客园 - 【当耐特】
Hugging Face - Blog
Hugging Face - Blog
M
MIT News - Artificial intelligence
博客园_首页
B
Blog RSS Feed
Recorded Future
Recorded Future
N
Netflix TechBlog - Medium
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
罗磊的独立博客
Apple Machine Learning Research
Apple Machine Learning Research
D
DataBreaches.Net
IT之家
IT之家
The GitHub Blog
The GitHub Blog
P
Proofpoint News Feed
Microsoft Azure Blog
Microsoft Azure Blog
S
SegmentFault 最新的问题
宝玉的分享
宝玉的分享
T
The Blog of Author Tim Ferriss
B
Blog
The Cloudflare Blog
MyScale Blog
MyScale Blog
雷峰网
雷峰网
U
Unit 42
C
Check Point Blog
月光博客
月光博客
Blog — PlanetScale
Blog — PlanetScale
T
Tailwind CSS Blog
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
大猫的无限游戏
大猫的无限游戏
D
Docker
Microsoft Security Blog
Microsoft Security Blog
WordPress大学
WordPress大学
L
LangChain Blog
F
Fortinet All Blogs
腾讯CDC
Martin Fowler
Martin Fowler
I
InfoQ
J
Java Code Geeks
博客园 - Franky
Engineering at Meta
Engineering at Meta
人人都是产品经理
人人都是产品经理
有赞技术团队
有赞技术团队
阮一峰的网络日志
阮一峰的网络日志

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