c# - Take a ScreenShot of my Control - Winform -
I want to take a screenshot of your control Winform I am using this function - Search this site:
Public Zero GetImage () {var bm = new bitmap (display1.Width, display1.Height); Display1.DrawToBitmap (BM, display1.ClientRectangle); BM. Save (@ "C: \ Whatever Jeff", image format.GF); } But when I am using it, then system me There is an error about System.Drawing.dll in System.Runtime.InteropServices.ExternalException '': A common error occurred in GDI +.
Do you have any ideas? Thanks!
---------------------- Edit ------------------ - --------
Well I have your function is altered in this way:
public void GetImage () {var bm = new bitmap (display1 .Width, Display 1.High); Display1.DrawToBitmap (BM, display1.ClientRectangle); Var dlg = new SaveFileDialog {DefaultExt = "png", filter = "Png files. * .png"}; var res = dlg.ShowDialog (); If (res == DialogResult.OK) BM Save (dlg.FileName, ImageFormat.Png); } And it works but I now have an empty picture:
Try the following: There is a rectangle assuming display1, which limits the area of the area on which you want to capture.
Public Zero GetImage () {rectangle display1 = this.Bounds; // // For the full screen using winforms control bounds // "= Screen.GetBounds (Point.Empty); var bm = new Bitmap (display1.Width, display1.Height); //display1.DrawToBitmap (BM, display1. ClientRectangle); graphics g = graphics. Fmaimej (BM); g. copy Fremskrin (new point (display 1. left display 1. helmet), point. Apti, display 1. Size); var Dielji = new Sevfail dialog {default Act = "png", filter = "png files | * .png "}; var res = dlg.ShowDialog (); if (res == DialogResult.OK) Bimksev (dlg.FileName, ImageFormat.Png);}
Comments
Post a Comment