VB.net 2010 视频教程 VB.net 2010 视频教程 python基础视频教程
SQL Server 2008 视频教程 c#入门经典教程 Visual Basic从门到精通视频教程
当前位置:
首页 > Python基础教程 >
  • C#教程之C#实现给图片加边框的方法

 
复制代码
 1  Bitmap bit= new Bitmap(@"" + Path);//给图片加边框
 2  //Bitmap bit = new Bitmap(Screen.AllScreens[0].Bounds.Size.Width, Screen.AllScreens[0].Bounds.Size.Height);//给当前桌面图加边框
 3  float w = (float)(bit.Width * 0.2);//边框的宽度,可取任意值
 4   using (Graphics g = Graphics.FromImage(bit))
 5   {
 6       // g.CopyFromScreen(0, 0, 0, 0, Screen.AllScreens[0].Bounds.Size);//抓取背景图
 7         using (Pen pen = new Pen(Color.White, w))
 8        { 
 9        //g.DrawRectangle(pen, new Rectangle(0, 0, Screen.AllScreens[0].Bounds.Size.Width, Screen.AllScreens[0].Bounds.Size.Height));//给当前桌面画白框
10         //g.DrawRectangle(pen, new Rectangle(0, 0, Math.Abs(bit.Width), Math.Abs(bit.Height)));//加边框
11          g.DrawEllipse(pen, new Rectangle(0, 0, Math.Abs(bit.Width), Math.Abs(bit.Height)));//加椭圆边框
12           g.Dispose();
13         // pic.BackgroundImage = bit;
14        } 
15    }
复制代码

 



相关教程