WinForm中:
/// <summary>
/// 获取整个屏幕的图片/// </summary>
/// <returns></returns>
public static Image GetScreenImage()
{
Image image = new Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height);
Graphics g = Graphics.FromImage(image);
g.CopyFromScreen(new Point(0, 0), new Point(0, 0), Screen.PrimaryScreen.Bounds.Size);
}
public static Image GetWinformImage()
{
//获取当前屏幕的图像
Bitmap b = new Bitmap(this.Width, this.Height);
this.DrawToBitmap(b, new Rectangle(0, 0, this.Width, this.Height));
//b.Save(yourFileName);
return b;
}