本文实例讲述了C#实现图片加相框的方法。分享给大家供大家参考,具体如下: //加边框try{ Bitmap Backbmp = new Bitmap(@"" + Path); float w = (float)(Backbmp.Width * 0.2); using (Graphics g = Graphics.FromImage
本文实例讲述了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#程序设计有所帮助。