`
iloveoracle
  • 浏览: 114328 次
  • 性别: Icon_minigender_1
  • 来自: 南京
社区版块
存档分类
最新评论

[转]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;}
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics