Atalasoft
Welcome to Atalasoft Community Sign in | Join | Help
in

Disposing the acquired image while scanning...

Last post 03 Dec 2007, 1:55 PM by scottb. 2 replies.
Sort Posts: Previous Next
  •  29 Nov 2007, 1:05 PM 12821

    Disposing the acquired image while scanning...

    We are developing in Visual Studio 2005 using C#.

    We have an older version (2.0) of DotTwain.

    My question arises from a sentence I saw in the help Docs for the AcquireEventArgs class.  In the "Remarks" section, it states: "It is the responsibility of the application to dispose of the image provided in the ImageAcquired event."  Because of that, I disposed of the image when done:

          private void acquisition_ImageAcquired(object sender, AcquireEventArgs e)

         {

              // Do acquire stuff...

              e.Image.Dispose();

         }

    This has caused problems, where in one of my applications I get an exception thrown from the driver that an object has no instance.  In another of my applications, it seems to work OK.  I'm trying to figure out if that Dispose() call should be in my code or not.

    Should I be trying to dispose of the image at the end of the ImageAcquired event?  If not, what does that "Remarks" comment indicate I should be doing?

    Thanks!

    -Scott Burrington

    Filed under:
  •  01 Dec 2007, 10:37 AM 12823 in reply to 12821

    Re: Disposing the acquired image while scanning...

    Yes, you should dispose the image after you are finished working with it.  DotTwain creates a new Bitmap for each page and doesn't access it once the ImageAcquired event has been raised.  The error you get should have nothing to do with disposing the image since the driver doesn't know that object even exists.

     


    Glenn Chittenden Jr.
    Atalasoft Development Team
  •  03 Dec 2007, 1:55 PM 12828 in reply to 12823

    Re: Disposing the acquired image while scanning...

    Hi Glenn,

    Hmmm. I shall investigate further why removing the "dispose" line caused my error to go away, then.

    Thanks!

View as RSS news feed in XML