I've looked for answers to this but can't figure out what's going wrong, basically the screencapture function below which creates and saves a bitmap to a file works fine the first time but throws this error when call a second time?? "A generic error occurred in GDI+"
public void Capture(int size, int x, int y, string fname)
{
using (Bitmap bmpScreenCapture = new Bitmap(size,size))
{
using (Graphics g = Graphics.FromImage(bmpScreenCapture))
{
g.CopyFromScreen(x,
y,
0, 0,
bmpScreenCapture.Size,
CopyPixelOperation.SourceCopy);
bmpScreenCapture.Save(fname, ImageFormat.Bmp);
}
}
}