Previous Up Next Introduction


This module, 'twain', provides an interface to the windows TWAIN sub-system. The software is available only for windows platforms. This software is designed to support scanners, digital cameras and audio equipment which conform to the twain specification.

The twain module also includes a demonstration program, called, which can be used to investigate the interface to your twain compatible device.

Introduction to TWAIN

TWAIN is a published API which provides an interface between an application and a scanner or other source of images. The TWAIN API is maintained and developed by TWAIN Working Group, see

The application connects to and communicates with the TWAIN Source Manager program, which is implemented as twain.dll. The TWAIN Source Manager loads the program to support the device with which your application needs to communicate. The program which supports the device is called a Data Source.

The TWAIN specification defines a simple finite-state model for communicating with the TWAIN sub-system. The states are as follows:

State NameState DescriptionApplication Activities Move to next state on
1 - Pre-SessionSource Manager is not Loaded NoneLoad DLL
2 - Source Manager LoadedSource Manager DLL has been loaded.NoneOpen Source Manager
3 - Source Manager OpenApplication can communicate with the source managerCan query the list of available sources Open Source
4 - Source OpenThe source for the appropriate device is open.Application can negotiate the details of the session, e.g. image format, number of colours etc.Request Aquisition of image
5 - Source EnabledThe source is attempting to acquire data on behalf of the applicationNoneUser/Source produce image
6 - Transfer ReadyThe source has acquired the data on behalf of the application.Begin the transfer.Transfer Started.
7 - Transfer in ProgressThe source is transferring the data to the application.Receive data.



Previous Up Next Introduction