0

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);
            }
        }
    }
tshepang
  • 11,360
  • 21
  • 88
  • 132
chillydk147
  • 285
  • 1
  • 9

0 Answers0