C#完成圖片加相框的辦法。本站提示廣大學習愛好者:(C#完成圖片加相框的辦法)文章只能為提供參考,不一定能成為您想要的結果。以下是C#完成圖片加相框的辦法正文
本文實例講述了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#法式設計有所贊助。