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

推荐订阅源

Y
Y Combinator Blog
有赞技术团队
有赞技术团队
J
Java Code Geeks
H
Hackread – Cybersecurity News, Data Breaches, AI and More
美团技术团队
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Hugging Face - Blog
Hugging Face - Blog
人人都是产品经理
人人都是产品经理
酷 壳 – CoolShell
酷 壳 – CoolShell
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
C
Check Point Blog
博客园 - 【当耐特】
The GitHub Blog
The GitHub Blog
Recent Announcements
Recent Announcements
The Cloudflare Blog
Microsoft Azure Blog
Microsoft Azure Blog
腾讯CDC
Vercel News
Vercel News
IT之家
IT之家
MyScale Blog
MyScale Blog
博客园_首页
Martin Fowler
Martin Fowler
WordPress大学
WordPress大学
罗磊的独立博客

博客园 - xujh

C# 同步两个子目录文件 ASP.NET中突破上传4M文件的限制 【转】一种在SQLServer中实现Sequence的高效方法 DevExpress的ASPxGridView中实现Master-Detail数据动态绑定 【转】浅谈:国内软件公司为何无法做大做强? - xujh - 博客园 一个正则表达式测试(只可输入中文、字母和数字) - xujh - 博客园 IE6、7下如何设置页面内部件高度和窗口等高(heihgt:100%) HP大中华区总裁孙振耀退休感言 C#的一个双缓冲显示的例子 【ASP.NET】防止ASP.NET按钮多次提交的办法 【ASP.NET】FCKeditor 2.6 + Asp.Net 设置 【ASP.NET】FreeTextBox的使用方法 在VS2005下配置手机设备仿真器访问局域网 [Delphi] 截屏存盘 有意思的加菲猫语录 [Delphi]用Delphi7访问.NET 2.0的WebService 转贴[ASP.NET]基于Forms认证的WebService应用 ASP.NET优秀博客搜集 [转贴]DataGrid中的高级ToolTip
C# 画圆角矩形
xujh · 2007-04-17 · via 博客园 - xujh

protected void Page_Load(object sender, EventArgs e)
{
        Bitmap bm 
= new Bitmap(800600);
        Graphics g 
= Graphics.FromImage(bm);
        g.FillRectangle(Brushes.White,
new Rectangle(0,0,800,600));
        FillRoundRectangle(g,Brushes.Plum,
new Rectangle(100100100100), 8);
        DrawRoundRectangle(g, Pens.Yellow,
new Rectangle(100100100100), 8);
        bm.Save(Response.OutputStream, ImageFormat.Jpeg);
        g.Dispose();
        bm.Dispose();
}

 
public static void DrawRoundRectangle(Graphics g,Pen pen,Rectangle rect, int cornerRadius)
{
        
using (GraphicsPath path = CreateRoundedRectanglePath(rect, cornerRadius))
        
{
            g.DrawPath(pen, path);
        }

}

public static void FillRoundRectangle(Graphics g, Brush brush,Rectangle rect, int cornerRadius)
{
        
using (GraphicsPath path = CreateRoundedRectanglePath(rect, cornerRadius))
        
{
            g.FillPath(brush, path);
        }

}

internal static GraphicsPath CreateRoundedRectanglePath(Rectangle rect, int cornerRadius)
{
        GraphicsPath roundedRect 
= new GraphicsPath();
        roundedRect.AddArc(rect.X, rect.Y, cornerRadius 
* 2, cornerRadius * 218090);
        roundedRect.AddLine(rect.X 
+ cornerRadius, rect.Y, rect.Right - cornerRadius * 2, rect.Y);
        roundedRect.AddArc(rect.X 
+ rect.Width - cornerRadius * 2, rect.Y, cornerRadius * 2, cornerRadius * 227090);
        roundedRect.AddLine(rect.Right, rect.Y 
+ cornerRadius * 2, rect.Right, rect.Y + rect.Height - cornerRadius * 2);
        roundedRect.AddArc(rect.X 
+ rect.Width - cornerRadius * 2, rect.Y + rect.Height - cornerRadius * 2, cornerRadius * 2, cornerRadius * 2090);
        roundedRect.AddLine(rect.Right 
- cornerRadius * 2, rect.Bottom, rect.X + cornerRadius * 2, rect.Bottom);
        roundedRect.AddArc(rect.X, rect.Bottom 
- cornerRadius * 2, cornerRadius * 2, cornerRadius * 29090);
        roundedRect.AddLine(rect.X, rect.Bottom 
- cornerRadius * 2, rect.X, rect.Y + cornerRadius * 2);
        roundedRect.CloseFigure();
        
return roundedRect;
}