The source code is as follows:
#region Save profile private void Button_save_click (object sender, EventArgs e) {SaveFileDialog s Aveimagedialog = new SaveFileDialog (); Saveimagedialog.title = "Save profile views"; Saveimagedialog.defaultext = ". png"; Saveimagedialog.filename = linefeaturelayer.name + "profile views"; Saveimagedialog.initialdirectory = "c:\\"; DialogResult dr = Saveimagedialog.showdialog (); if (Dr==dialogresult.ok) {captureimage (saveimagedialog.filename); MessageBox.Show ("Saved successfully! "); }} private void Captureimage (string path) {try {//Get the current screen size Rectangle rect = new Rectangle (); Rect = Screen.getworkingarea (this); Create an image with the current screen as a template graphics G1 = this. CreateGraphics (); Creates a bitmap with a screen size of Image myimage = new Bitmap (rect. Width, Rect. Height,G1); Graphics g2 = Graphics.fromimage (myimage); Get the screen DC IntPtr DC1 = G1. GetHdc (); Get bitmap dc IntPtr DC2 = G2. GetHdc (); Call this API function to implement screen capture BitBlt (DC2, 0, 0, rect. Width, Rect. Height, DC1, 0, 0, 13369376); Release the DC G1 of the screen. RELEASEHDC (DC1); Release the bitmap DC G2. RELEASEHDC (DC2); Save Myimage.save (Path, imageformat.png) in JPG file format; } catch (System.Exception ex) {MessageBox.Show (ex. Message + "Save picture Failed!" "); }}//Declare an API function [System.Runtime.InteropServices.DllImportAttribute ("Gdi32.dll")] Private static extern bool BitBlt (INTPTR hdcdest,//Handle of the target DC int nxdest, int nyde St, int nwidth, int nheight, IntPtr hdcsrc,//Handle of source DC int nxsrc, int nysrc, System.Int32 dwrop//raster processing value); #endregion :