I have recently tried to make a screen recorder, but i'm keep getting this error: "An unhandled exception of type 'System.ArgumentException' occurred in System.Drawing.dll" and the Additional Information: "Parameter not valid". This is the code i have so far:
`
private Bitmap captureScreen()
{
Size s = Screen.PrimaryScreen.Bounds.Size;
Bitmap bm = new Bitmap(s.Width, s.Height);
Graphics g = Graphics.FromImage(bm);
g.CopyFromScreen(0, 0, 0, 0, s);
return bm;
}
private void screenCapturer_Tick(object sender, EventArgs e) //timer
{
screenPreview.Image = captureScreen();
}
`
The error occurs some time after the form has loaded. When i change the interval of the timer the error occurs later.
Thanks.