Search...

Monday, June 4, 2012

Take Screenshot in C#


using System;
using System.Drawing;
using System.Drawing.Imaging;

namespace TakeScreenshot
{
    class Program
    {
        static void Main(string[] args)
        {
            new Screenshot().TakeScreenshot();
        }
    }

    class Screenshot
    {
        public Screenshot() { }

        public void TakeScreenshot()
        {
            Bitmap bitmap = new Bitmap(1024, 768);

            Graphics graphics = Graphics.FromImage(bitmap as Image);

            graphics.CopyFromScreen(0, 0, 0, 0, bitmap.Size);

            bitmap.Save("c:\\screenshot.jpeg", ImageFormat.Jpeg);

        }
    }
}

No comments: