您的位置:时时app平台注册网站 > 编程知识 > C#达成给图片加边框的主意

C#达成给图片加边框的主意

2019-10-13 18:41
 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    }

 

 

本文由时时app平台注册网站发布于编程知识,转载请注明出处:C#达成给图片加边框的主意

关键词: