winform C# 怎么在背景图上面用Gdi画出圆角矩形边框

qq_29783739 2015-09-01 11:50:11
如图
...全文
322 2 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
bdmh 2015-09-01
  • 打赏
  • 举报
回复
圆角需要你自己绘制,四条直线,不要画到头,留一点地方绘制圆弧,函数都是有的
qq_29783739 2015-09-01
  • 打赏
  • 举报
回复
private GraphicsPath RoundRect(Rectangle r, int round) { GraphicsPath gp = new GraphicsPath(); r.Width = r.Width - 1; r.Height = r.Height - 1; int x = r.X; int y = r.Y; int w = r.Width; int h = r.Height; gp.AddArc(x, y, round, round, 180, 90); gp.AddArc(w - round, y, round, round, 270, 90); gp.AddArc(w - round, h - round, round, round, 0, 90); gp.AddArc(x, h - round, round, round, 90, 90); gp.CloseAllFigures(); return gp; } public void huaxian() //绘线条 { Bitmap im = (Bitmap)this.panel1.BackgroundImage; Graphics mygraphics = Graphics.FromImage(im); Pen mypen = new Pen(Color.Black, 5); mygraphics.DrawPath(new Pen(Color.Black, 5), RoundRect(this.panel1.ClientRectangle, 50)); mygraphics.Dispose(); this.panel1.BackgroundImageLayout = ImageLayout.Tile; this.panel1.BackgroundImage = im; } private void button1_Click(object sender, EventArgs e) { huaxian(); } 这是我写的方法为什么没效果呢

8,833

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 组件/控件开发
社区管理员
  • 组件/控件开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧