Using System; using System. collections. generic; using System. componentModel; using System. data; using System. drawing; using System. linq; using System. drawing. imaging; using System. text; using System. windows. forms;
Namespace WindowsFormsApplication4 {public partial class Form1: Form {public Form1 () {InitializeComponent ();}
Private void button#click (object sender, EventArgs e) {CaptureImage (this. location, new Point (0, 0), new Rectangle (this. location. x, this. location. y, this. width, this. height), "c: \ ls.bmp ");}
Public void CaptureImage (Point SourcePoint, Point DestinationPoint, Rectangle SelectionRectangle, string FilePath) {using (Bitmap bitmap = new Bitmap (SelectionRectangle. width, SelectionRectangle. height) {using (Graphics g = Graphics. fromImage (bitmap) {g. copyFromScreen (SourcePoint, DestinationPoint, SelectionRectangle. size);} bitmap. save (FilePath, ImageFormat. bmp); bitmap. dispose ();}}}
}