The examples in this article describe how C # implements screen copies. Share to everyone for your reference. Specific as follows:
Method One:
Using system;using system.collections.generic;using system.componentmodel;using system.data;using System.Drawing; Using system.text;using system.windows.forms;using system.drawing.drawing2d;namespace WindowsApplication2{ public partial class Form21:form {public Form21 () { InitializeComponent (); } private void Button1_Click (object sender, EventArgs e) { Rectangle screenrect = Screen.PrimaryScreen.WorkingArea; Bitmap Dumpbitmap = new Bitmap (screenrect.width, screenrect.height); Graphics TG = graphics.fromimage (dumpbitmap); Tg. CopyFromScreen (0, 0, 0, 0, New Size (Dumpbitmap.width, Dumpbitmap.height)); This.pictureBox1.BackgroundImage = Dumpbitmap; This.pictureBox1.BackgroundImageLayout = Imagelayout.stretch; Dumpbitmap.save (@ "c:/image1.bmp");}}}
Method Two:
Using system;using system.collections.generic;using system.componentmodel;using system.data;using System.Drawing; Using system.text;using system.windows.forms;namespace windowsapplication2{public partial class Form22:form {public Form22 () { InitializeComponent (); } private void Button1_Click (object sender, EventArgs e) { Rectangle rect = new Rectangle (0, 0, this. Size.width, this. Size.Height); Bitmap Dumpbitmap = new Bitmap (this. Size.width, this. Size.Height); This. DrawToBitmap (Dumpbitmap, rect); This.pictureBox1.BackgroundImage = Dumpbitmap; This.pictureBox1.BackgroundImageLayout = Imagelayout.stretch; Dumpbitmap.save (@ "c:/image2.bmp");}}}
I hope this article is helpful to everyone's C # programming.