Keep on getting error: System.Runtime.InteropServices.ExternalException: 'A generic error occurred in GDI+.'

  • Thread starter Thread starter Zombae
  • Start date Start date
Z

Zombae

Guest
Keep on getting error: System.Runtime.InteropServices.ExternalException: 'A generic error occurred in GDI+.'

it only happens on the third time I run the function.

Here is my code that I will supply for you:

string image = "C://Users/giann/PRIVACYREASONS/edimages/screenshot1.png";


//Take Screenshot
private void TakeScreenshot()
{
Rectangle bounds = Screen.GetBounds(Point.Empty);
using (Bitmap bitmap = new Bitmap(bounds.Height - 935, bounds.Width - 1890))
{
using (Graphics g = Graphics.FromImage(bitmap))
{
g.CopyFromScreen(new Point(1030, 470), new Point(0, 0), bounds.Size);
}
bitmap.Save(image, ImageFormat.Png);
}
}

Im using these:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Drawing.Imaging;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.IO;
using IronOcr;
using System.Runtime.InteropServices;

Continue reading...
 
Back
Top