Record a video of the screen using .NET technologies [closed]

There isn’t any need for a third-party DLL. This simple method captures the current screen image into a .NET Bitmap object.

    private Image CaptureScreen()
    {
        Rectangle screenSize = Screen.PrimaryScreen.Bounds;
        Bitmap target = new Bitmap(screenSize.Width, screenSize.Height);
        using(Graphics g = Graphics.FromImage(target))
        {
            g.CopyFromScreen(0, 0, 0, 0, new Size(screenSize.Width, screenSize.Height));
        }
        return target;
    }

I am sure you can figure out how to capture a smaller portion of the screen, if that is needed :-).

Leave a Comment