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

推荐订阅源

博客园 - 三生石上(FineUI控件)
月光博客
月光博客
S
SegmentFault 最新的问题
有赞技术团队
有赞技术团队
Stack Overflow Blog
Stack Overflow Blog
Engineering at Meta
Engineering at Meta
T
The Blog of Author Tim Ferriss
The GitHub Blog
The GitHub Blog
小众软件
小众软件
Hugging Face - Blog
Hugging Face - Blog
IT之家
IT之家
宝玉的分享
宝玉的分享
A
About on SuperTechFans
Vercel News
Vercel News
P
Proofpoint News Feed
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
博客园 - 【当耐特】
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
V
Visual Studio Blog
Jina AI
Jina AI
Y
Y Combinator Blog
T
Tailwind CSS Blog
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Last Week in AI
Last Week in AI

博客园 - Emosen

Win7 不能安装SQL Server 2005 Management Studio Express.msi解决办法 WINDOWS 画空心字 - Emosen - 博客园 ZT--文本显示尺寸计算(关于控件的尺寸定义) create database link 数据库主键设计之思考 开始→运行→输入的命令集锦 开发人员一定要加入收藏夹的网站 SQL Server 2005 Express 远程访问设置方法 Microsoft SQL Server 2005 Express 远程访问设置详述,100%成功篇 编程十诫 转贴:最常见问题(FAQ)留着慢慢学习--微软.net精简框架最常见问题 ndis 相关资料 PHP+PDO+ORALCE 实例演示 PHP+PDO+ORALCE 配置说明 Oracle 数据类型 Oracle分页查询语句(一) 网页UTF8编码--多出空白行的问题(ZT) 开源性能测试工具 - ApacheBench(简称ab) 介绍 用Eclipse开发PHP项目
C# 改变图片大小的功能代码片段 (wince5)
Emosen · 2009-04-14 · via 博客园 - Emosen

                if (pictureBox1.Image == null) return;
                Bitmap srcmap = null, destbit =null;
                Graphics g = null;
                try
                {
                    //例如:图片目标大小为:320*240

                    GC.Collect();GC.WaitForPendingFinalizers();
                    srcmap = new Bitmap(pictureBox1.Image);
                    //Bitmap srcmap = new Bitmap(strImageFile);
                    //图片文件=strImageFile,直接NEW出某图片文件时,如图片太太会出现OutOfMemory的异常哦,不知如何解决@@
                    destbit = new Bitmap(320, 240);
                    Rectangle srcRec = new Rectangle(0, 0, srcmap.Width, srcmap.Width);
                    Rectangle destRec = new Rectangle(0, 0,  320,240);
                    g = Graphics.FromImage(destbit);
                    g.DrawImage(srcmap, destRec, srcRec, GraphicsUnit.Pixel);
                    destbit.Save(fileName, System.Drawing.Imaging.ImageFormat.Jpeg);//保存较大Jpeg,如1280*1024图片时,比较消耗内在哦。
                    if (g != null) { g.Dispose(); g = null; }
                    if (destbit != null) { destbit.Dispose(); destbit = null; }
                    if (srcmap != null) { srcmap.Dispose(); srcmap = null; }
                    GC.Collect();GC.WaitForPendingFinalizers();

                }
                catch (Exception ex)
                {
                    if (g != null) { g.Dispose(); g = null; }
                    if (destbit != null) { destbit.Dispose(); destbit = null; }
                    if (srcmap != null) { srcmap.Dispose(); srcmap = null; }
                    GC.Collect();GC.WaitForPendingFinalizers();
                   

                    MessageBox.Show(ex.Message);
                }

                //如果大家有更好的方法,请多多指教,TKS!

                参考源:http://www.vbforums.com/showthread.php?t=560892