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

推荐订阅源

博客园 - 【当耐特】
Stack Overflow Blog
Stack Overflow Blog
V
Visual Studio Blog
小众软件
小众软件
The Cloudflare Blog
T
Tailwind CSS Blog
Apple Machine Learning Research
Apple Machine Learning Research
爱范儿
爱范儿
美团技术团队
WordPress大学
WordPress大学
罗磊的独立博客
Microsoft Azure Blog
Microsoft Azure Blog
A
About on SuperTechFans
Last Week in AI
Last Week in AI
月光博客
月光博客
博客园 - Franky
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
G
Google Developers Blog
GbyAI
GbyAI
B
Blog
大猫的无限游戏
大猫的无限游戏
博客园 - 聂微东
Hugging Face - Blog
Hugging Face - Blog
博客园 - 叶小钗

博客园 - Ame

将项目改为windows 服务的步骤 js 设为首页,加入收藏夹 - Ame - 博客园 FCKeditor 的使用心得 IE,firefox 里对浏览器事件处理的兼容性处理 - Ame - 博客园 项目中的JS ,alert 出现乱码 Jquery 插件参考 报表实现的参考 RDLC 矩阵使用 - Ame - 博客园 ajaxpro 的使用心得 - Ame - 博客园 [转]ReportViewer 2008的部署 Reporting services 权限 经典正则表达式 [转载] iframe和跨站点cookie被阻止 (转载) js 动态生成HTML,并加载事件遇到的问题 - Ame - 博客园 jquery.cookies 的使用心得[仅做自己记忆所用] 一些药物的副作用 一些食物的用法 Blogs Flog Fat 蜂蜜知识大全 - Ame - 博客园
压缩图片 - Ame - 博客园
Ame · 2010-06-29 · via 博客园 - Ame

 public void CreateThumbnailImage() 

 { 

     string imgFile = "e:/test.jpg"; 

     System.Drawing.Image img = System.Drawing.Image.FromFile(imgFile); 

     System.Drawing.Image.GetThumbnailImageAbort cb = new System.Drawing.Image.GetThumbnailImageAbort(CallBack); 

     System.Drawing.Image thumbnailImage = img.GetThumbnailImage(120, 120, cb, System.IntPtr.Zero); 

     string extendName = imgFile.Substring(imgFile.LastIndexOf(".") + 1); 

     ImageFormat imgFormat = GetImageFormat(extendName); 

     thumbnailImage.Save("e:/result.jpg",imgFormat); 

 } 

 public bool CallBack() 

 { 

     return     false; 

 }

 //获得图片格式 

        private static ImageFormat GetImageFormat(String extendName)
        {
            extendName = extendName.ToLower();
            switch (extendName)
            {
                case "gif":
                    return ImageFormat.Gif;
                case "jpg":
                case "jpeg":
                    return ImageFormat.Jpeg;
                case "bmp":
                    return ImageFormat.Bmp;
                case "wmf":
                    return ImageFormat.Emf;
                case "exif":
                    return ImageFormat.Exif;
                case "icon":
                    return ImageFormat.Icon;
                case "tiff":
                    return ImageFormat.Tiff;
                default:
                    return ImageFormat.Png;
            }
        }