C#实现图片加相框的方法
程序员文章站
2022-05-25 23:10:28
本文实例讲述了c#实现图片加相框的方法。分享给大家供大家参考,具体如下:
//加边框
try
{
bitmap backbmp = new bitmap...
本文实例讲述了c#实现图片加相框的方法。分享给大家供大家参考,具体如下:
//加边框 try { bitmap backbmp = new bitmap(@"" + path); float w = (float)(backbmp.width * 0.2); using (graphics g = graphics.fromimage(backbmp)) { using (brush brush = new solidbrush(color.fromargb(0, 156, 255))) { using (pen pen = new pen(brush, w)) { pen.dashstyle = dashstyle.custom; g.drawrectangle(pen, new rectangle(0, 0, math.abs(backbmp.width), math.abs(backbmp.height))); g.dispose(); pic.backgroundimage = backbmp; } } } } catch (exception) { } //加椭圆 try { bitmap backbmp = new bitmap(@"" + path); float w = (float)(backbmp.width * 0.2); using (graphics g = graphics.fromimage(backbmp)) { using (brush brush = new solidbrush(color.fromargb(0, 156, 255))) { using (pen pen = new pen(brush, w)) { pen.dashstyle = dashstyle.custom; g.drawellipse(pen, new rectangle(0, 0, math.abs(backbmp.width), math.abs(backbmp.height))); g.dispose(); pic.backgroundimage = backbmp; } } } } catch (exception) { }
更多关于c#相关内容感兴趣的读者可查看本站专题:《c#面向对象程序设计入门教程》、《c#常见控件用法教程》及《c#数据结构与算法教程》
希望本文所述对大家c#程序设计有所帮助。