I am creating a LPR (License Plate Reader) in C#.
My code is based on getting an image from camera and saving it in a location, then the LPR process the image to plain text .
So every time the image taken by the cam should be replaced by new one.
But when I try to save the image for the second time, I get this error.
Here is where the problem starts.
if (pictureBox3.Image != null)
{
Bitmap varBmp = new Bitmap(pictureBox3.Image);
Bitmap newBitmap = new Bitmap(varBmp);
//Save First
varBmp.Save(Application.StartupPath + "\\ImageTest\\1.bmp", ImageFormat.Bmp);
//Now Dispose to free the memory
varBmp.Dispose();
varBmp = null;
}
else
{
MessageBox.Show("null exception");
}
I dispose the image after saving it, still instead of replacing i get this why?
I am adding more details, every time when the image is created it is processed all over by different function and events. I think those things might be holding that particular image...
Snap click http://pastebin.com/QHXkqATb
Process image http://pastebin.com/MpAVacDr
OCR (optical character Recognizer) http://pastebin.com/sXPxzQ39
Find License Plate http://pastebin.com/DH1SdebL
I have an imagebox and picture box1 which is holding these images for processing, therfore if you focus on that area you can find the error.
Any help is appreciated.