[转]c# 画圆角矩形_JAVA_编程开发_程序员俱乐部

中国优秀的程序员网站程序员频道CXYCLUB技术地图
热搜:
更多>>
 
您所在的位置: 程序员俱乐部 > 编程开发 > JAVA > [转]c# 画圆角矩形

[转]c# 画圆角矩形

 2011/12/1 8:39:16  iloveoracle  http://iloveoracle.iteye.com  我要评论(0)
  • 摘要:本文转自:http://www.cnblogs.com/xujh/archive/2008/05/12/717433.htmlprotectedvoidpage_load(objectsender,eventargse){bitmapbm=newbitmap(800,600);graphicsg=graphics.fromimage(bm);g.fillrectangle(brushes.white,newrectangle(0,0,800,600));fillroundrectangle(g
  • 标签:C#
    本文转自:http://www.cnblogs.com/xujh/archive/2008/05/12/717433.htmlprotectedvoidpage_load(objectsender,eventargse){bitmapbm=newbitmap(800,600);graphicsg=graphics.fromimage(bm);g.fillrectangle(brushes.white,newrectangle(0,0,800,600));fillroundrectangle(g,brushes.plum,newrectangle(100,100,100,100),8);drawroundrectangle(g,pens.yellow,newrectangle(100,100,100,100),8);bm.save(response.outputstream,imageformat.jpeg);g.dispose();bm.dispose();}publicstaticvoiddrawroundrectangle(graphicsg,penpen,rectanglerect,intcornerradius){using(graphicspathpath=createroundedrectanglepath(rect,cornerradius)){g.drawpath(pen,path);}}publicstaticvoidfillroundrectangle(graphicsg,brushbrush,rectanglerect,intcornerradius){using(graphicspathpath=createroundedrectanglepath(rect,cornerradius)){g.fillpath(brush,path);}}internalstaticgraphicspathcreateroundedrectanglepath(rectanglerect,intcornerradius){graphicspathroundedrect=newgraphicspath();roundedrect.addarc(rect.x,rect.y,cornerradius*2,cornerradius*2,180,90);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*2,270,90);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*2,0,90);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*2,90,90);roundedrect.addline(rect.x,rect.bottom-cornerradius*2,rect.x,rect.y+cornerradius*2);roundedrect.closefigure();returnroundedrect;}
发表评论
用户名: 匿名