گرفتن ScreenShot از صفحه نمایش

برای عکس گرفتن از صفحه دسکتاب یک دکمه بر روی فرم مانند شکل زیر قرار دهید :

Capture ScreenShot from the screen

حال بر روی دکمه دوبار کلیک کرده و کد زیر را در کنترل کننده رویداد کلیک آن بنویسید :

private void button1_Click(object sender, EventArgs e)
{
        int screenWidth = Screen.PrimaryScreen.Bounds.Width;
	int screenHeight = Screen.PrimaryScreen.Bounds.Height;

	Graphics Graphics1;
	Bitmap Bitmap1 = new Bitmap(screenWidth, screenHeight);
	Graphics1 = Graphics.FromImage(Bitmap1);
	Graphics1.CopyFromScreen(Point.Empty, Point.Empty, Screen.PrimaryScreen.Bounds.Size);
	Bitmap1.Save(@"c:\1.bmp");
}

برنامه را اجرا کرده و بر روی دکمه کلیک نمایید. به درایو C رفته ، مشاهده می کنید که عکسی با نام و پسوند 1.bmp ذخیره شده است.