Can someone help me with code to capture a screenshot of the teststack.white window? I tried the following code
Rectangle bounds = this.Bounds;
using (Bitmap bitmap = new Bitmap(bounds.Width, bounds.Height))
{
using (Graphics g = Graphics.FromImage(bitmap))
{
g.CopyFromScreen(new System.Drawing.Point(bounds.Left, bounds.Top), System.Drawing.Point.Empty, bounds.Size);
}
bitmap.Save(@"C:\Users\Desktop\test.jpg", System.Drawing.Imaging.ImageFormat.Jpeg);
}
This captures a screenshot of the form. If in place of this.bounds , I key in the teststack.white window bounds, it says cannot convert system.windows.rect to system.drawing.rectangle? Can someone provide me with the code to get this sorted? Thanks in advance.
Sure, it's easy:
Desktop.TakeScreenshot("C:\\white-framework.png", System.Drawing.Imaging.ImageFormat.Png);
If you need to manipulate the image after capturing it, you can do this:
Bitmap bitmap = Desktop.CaptureScreenshot();
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.