• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

asp.netGDI+使用PathGradienBrush类实现彩色渐变

原作者: [db:作者] 来自: [db:来源] 收藏 邀请
 1 using System;
 2 using System.Collections.Generic;
 3 using System.Linq;
 4 using System.Web;
 5 using System.Web.UI;
 6 using System.Web.UI.WebControls;
 7 using System.Drawing;
 8 using System.Drawing.Drawing2D;
 9 
10 public partial class _Default : System.Web.UI.Page
11 {
12     protected void Page_Load(object sender, EventArgs e)
13     {
14         Bitmap bitmap = new Bitmap(400, 200);
15         Graphics graphics = Graphics.FromImage(bitmap);
16         graphics.Clear(Color.White);
17         Point centerPoint = new Point(100, 100);
18         int r = 100;
19         GraphicsPath path = new GraphicsPath();
20         path.AddEllipse(centerPoint.X - r, centerPoint.Y - r, 2 * r, 2 * r);
21         PathGradientBrush mypathgradientBrush = new PathGradientBrush(path);
22         mypathgradientBrush.CenterPoint = centerPoint;
23         mypathgradientBrush.CenterColor = Color.DarkGreen;
24         mypathgradientBrush.SurroundColors = new Color[] { Color.Gold };
25         graphics.FillEllipse(mypathgradientBrush, centerPoint.X - r, centerPoint.Y - r, 2 * r, 2 * r);
26         centerPoint = new Point(300, 100);
27         r = 33;
28         path = new GraphicsPath();
29         path.AddEllipse(centerPoint.X - r, centerPoint.Y - r, 2 * r, 2 * r);
30         path.AddEllipse(centerPoint.X - 2*r, centerPoint.Y - 2*r, 4 * r, 4 * r);
31         path.AddEllipse(centerPoint.X - 3 * r, centerPoint.Y - 3 * r, 6 * r, 6 * r);
32         mypathgradientBrush = new PathGradientBrush(path);
33         mypathgradientBrush.CenterPoint = centerPoint;
34         mypathgradientBrush.CenterColor = Color.Gold;
35         mypathgradientBrush.SurroundColors = new Color[] { Color.Black, Color.Blue, Color.DarkGreen };
36         graphics.FillPath(mypathgradientBrush, path);
37         System.IO.MemoryStream ms = new System.IO.MemoryStream();
38         bitmap.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);
39         Response.ClearContent();
40         Response.ContentType = "image/Jpeg";
41         Response.BinaryWrite(ms.ToArray());
42     }
43 }

 


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
[目录]ASP.NetCore搭建微服务网站发布时间:2022-07-10
下一篇:
我学习ASP.Net的过程和对初学者的一些建议发布时间:2022-07-10
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap