Hello,
I am getting a General GDI+ Error according to the Visual C# debugger. i have no idea as to how to handle this problem. I have a button which i click and a section of the screen is cut and put into a bitmap. This is converted into tiff format which is sent for OCR using MODI. The first time I click the button it works, however, when i click the button again, I get a the error. Here is the line it is being pointed to:

bitonalBitmap.Save(@"c:\Bitonal-Out.tif", imageCodecInfo, encoderParameters);

Can anyone help me please.
Thanks in advance.

I added a
try
{
code
}
catch...
Im finding that every second time I click the button, it works... if that helps anyone to understand this better...

First, have u got any more information on the type of exception you are getting? and what exactly is the error message?

Sorry, should have posted that as well...

See the end of this message for details on invoking
just-in-time (JIT) debugging instead of this dialog box.

************** Exception Text **************
System.Runtime.InteropServices.ExternalException: A generic error occurred in GDI+.
at System.Drawing.Image.Save(String filename, ImageCodecInfo encoder, EncoderParameters encoderParams)
at BitonalConverter.Form1.OCRProcess(Int32 StartX, Int32 StartY, Int32 EndX, Int32 EndY, String file) in C:\Documents and Settings\user\Desktop\Bitonal\BitonalImageConverter_src\Bitonal\Bitonal.cs:line 58
at BitonalConverter.Form1.Process_Click(Object sender, EventArgs e) in C:\Documents and Settings\user\Desktop\Bitonal\BitonalImageConverter_src\Bitonal\Bitonal.cs:line 111
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

Maybe this will help... I tried to delete the Bitmap after and was getting a "File used in another process error" which i also posted on another thread

Do you dispose of all your resources after the 1st button click? Do you specify a filename or is it a static filename you are using? sorry for all the questions im trying to determine more or less what may be the cause of this exception

Do you dispose of all your resources after the 1st button click? Do you specify a filename or is it a static filename you are using? sorry for all the questions im trying to determine more or less what may be the cause of this exception

Yes we do same as you mentioned.
Please reply me for the solution.

This article has been dead for over six months. Start a new discussion instead.