i successfully used TwainAcquireToGdPictureImage to get a TIF from my TWAIN device. (currently a webcam - will be replaced by a scanner later)
Now i tried to run this whole stuff in a worker thread. It works exactely for one time. If i try to get a picture from my webcam again, TwainAcquireToGdPictureImage return 0 and it hangs at TwainUnloadSourceManager
Here is the core of the TWAIN acquire... Not that magical but i have no idea why the second scan doesnt work...
- Code: Select all
if (!GdLib.TwainOpenDefaultSource(IntPtr.Zero))
return false;
int ImageID = GdLib.TwainAcquireToGdPictureImage(IntPtr.Zero); //returning 0 at second run
if (ImageID != 0)
{
GdLib.SaveAsTIFF(ImageID, path, (TiffCompression)ScanServiceCompression.TiffCompressionLZW);
GdLib.ReleaseGdPictureImage(ImageID);
}
GdLib.TwainCloseSource();
GdLib.TwainUnloadSourceManager(IntPtr.Zero); //hangs at second run
The second question... I tried to disable the TWAIN UI but that method has no effect...
GdLib.TwainSetHideUI(true);
Is is possible to hide the TWAIN UI and to get an image automatically from the default twain source?
best regards
dix

