ImageGear .NET
Acquiring Images from TWAIN Devices

TWAIN was developed by a consortium of software and hardware manufacturers to standardize the communications between application programs and image acquisition devices. The interface is optimized for the acquisition of graphics images. The TWAIN standard is widely supported by scanner manufacturers. The most widely used version of TWAIN is v1.9 (as of this writing). In addition to scanners, TWAIN is being used with digital cameras and video capture boards. ImageGear supports all three TWAIN Transfer Modes: Native Data Transfer Mode (which is the TWAIN default), Disk File Transfer, and Buffered Memory.

A TWAIN-compliant image acquisition device is one whose device driver complies with the TWAIN specification. The device driver understands the TWAIN protocol, thus allowing interaction with the Data Source Manager, the main interface module of the TWAIN software. The Data Source Manager "manages the session" between the application program and the raster-generating data source. Three software elements work together in TWAIN: the application, the Data Source (DS), and the Data Source Manager (DSM) as shown in the illustration below: 

The following terminology is used to discuss ImageGear scanning:

The TWAIN Data Source for your device and the TWAIN Data Source Manager should be included as part of your scanner software. They are not part of the ImageGear software.

The process of acquiring an image (or set of images) from a device is as follows:

  1. Open the Data Source. This can be done automatically by the application (it chooses the Data Source for the end-user). Alternatively, the application can obtain a list of Data Sources from the Data Source Manager and let the end-user choose, or the application can have ImGearTWAIN Class display the list via its standard dialog box.
  2. Set the image acquisition parameters (single-page, multi-page, image size, etc.). This can be done automatically by the application, or the application can obtain the various Data Source capabilities (called "ScanCaps"), display them to the end-user in a dialog, and let the end-user choose the values. Alternatively, the application can let ImGearTWAIN Class obtain the settings from the end-user via its standard ScanCaps dialog. See ImGearCapabilities for a list of supported capabilities.
  3. Acquire the image(s). Each image is loaded into an ImGearPage Class object. For a multi-page acquisition, the ImGearPages are loaded into an ImGearDocument Class.
  4. Close the Data Source.

Thus, an example of the code needed to acquire an image from a TWAIN Data Source is as follows:

C#
Copy Code
ImGearTWAIN igTWAIN = new ImGearTWAIN();
igTWAIN.WindowHandle = this.Handle;
igTWAIN.UseUI = true;
// Open a data source
igTWAIN.OpenSource("");
// Set simplex mode
ImGearCapOneValue igCapOneValue = new ImGearCapOneValue(ImGearCapabilities.CAP_DUPLEXENABLED);
igCapOneValue.Value = false;
igTWAIN.SetCapability(igCapOneValue, ImGearMessages.SET);
// Acquire image
ImGearPage igPage = igTWAIN.AcquireToPage();
// Close the data source
igTWAIN.CloseSource();

 

 


©2017. Accusoft Corporation. All Rights Reserved.

Send Feedback