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 }