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

推荐订阅源

D
DataBreaches.Net
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Google DeepMind News
Google DeepMind News
博客园 - 聂微东
Microsoft Azure Blog
Microsoft Azure Blog
V
Visual Studio Blog
IT之家
IT之家
博客园 - 【当耐特】
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
B
Blog
爱范儿
爱范儿
阮一峰的网络日志
阮一峰的网络日志
云风的 BLOG
云风的 BLOG
Vercel News
Vercel News
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
H
Hackread – Cybersecurity News, Data Breaches, AI and More
H
Help Net Security
J
Java Code Geeks
aimingoo的专栏
aimingoo的专栏
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
B
Blog RSS Feed
Blog — PlanetScale
Blog — PlanetScale
S
SegmentFault 最新的问题
Apple Machine Learning Research
Apple Machine Learning Research

博客园 - 随风

释放C盘空间的27招优化技巧 数据库索引应用(ms-sql) 使用命令行导入导出方案(oracle) 使用C#调用DTS包 网页效果集合(小技巧) - 随风 - 博客园 ORACLE常用傻瓜問題1000問 网络命令一览表 自定义应用程序配置文件(app.config) XmlHttp异步获取网站数据 - 随风 - 博客园 页面无刷新获取数据的几种方式浅析 利用XMLHTTP无刷新添加数据 利用XMLHTTP无刷新自动实时更新数据 数据完整性管理 推模式中的水晶报表参数赋值 有关打印、收藏等的JS代码(打印等主要使用了一个IE组件来实现) C#操作注册表 对虚拟目录的操作 SOS!! 求助 如何在asp.net中保存用户状态
C#图像处理
随风 · 2005-04-22 · via 博客园 - 随风

前段时间在写一个公司层级动态呈现的图形处理功能,对C#的图形处理有了大致的了解,现整理如下:
一、生成图片并实现颜色渐变效果
    Response.Clear(); 
   Bitmap imgOutput = new Bitmap(100, 50); 
   Graphics gic = Graphics.FromImage(imgOutput);

   gic.Clear(Color.BlueViolet);
   gic.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
   gic.DrawString("渐变图形", new Font("黑体",16,FontStyle.Italic),new SolidBrush(Color.White),new PointF(2,2)); 
   gic.FillRectangle(new System.Drawing.Drawing2D.LinearGradientBrush(new Point(0,0), new Point(100,50), Color.FromArgb(0,0,0,0),Color.FromArgb(255,255,255,255)),0,0,100,50); 

   imgOutput.Save(Response.OutputStream, System.Drawing.Imaging.ImageFormat.Jpeg);
   gic.Dispose(); 
   imgOutput.Dispose(); 
   Response.End(); 

二、对图片进行反转
    System.Drawing.Image drawimage = System.Drawing.Image.FromFile(photopath);//photopath表示图片的物理地址
   drawimage.RotateFlip(RotateFlipType.Rotate270FlipNone);
    if(File.Exists(photopath))
   {
        File.SetAttributes(photopath,FileAttributes.Normal);
        File.Delete(photopath);
   }
   drawimage.Save(photopath,System.Drawing.Imaging.ImageFormat.Jpeg);
   drawimage.Dispose();

三、对图片进行缩放
    System.Drawing.Image drawimage = System.Drawing.Image.FromFile(photopath);
   Bitmap imgOutput = new Bitmap(drawimage,60,30);
   imgOutput.Save(newphotppath, System.Drawing.Imaging.ImageFormat.Jpeg); 
   imgOutput.Dispose();  
   Response.End();

其他还有一些画线、画矩形、画圆等的函数和方法都可以在System.Drawing中找到;