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. 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:
- Data Source: Software provided by the manufacturer of the device. Windows refers to this as a "Device Driver". It must be installed in the system where your application program will run.
- Data Source Manager: The TWAIN manager for the device drivers. This is software developed by the TWAIN consortium to provide a common mechanism for managing and using the Data Sources from all the different device manufacturers. It must be installed in the system where your application will run.
- Device: Any device from which images can be acquired using the TWAIN protocol, including scanners and cameras.
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:
- 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.
- 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.
- 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.
- Close the Data Source.
Thus, an example of the code needed to acquire an image from a TWAIN Data Source is as follows: