Acquiring without a User Interface or Implementing a Custom Source UI

Top  Previous  Next

DTWAIN allows you to implement a custom user interface (UI) or turn off the user interface altogether when the Source is ready to acquire an image.  However, there are Sources that do not allow you to use a customized UI or turn off the user interface. The Source UI can only be turned off if and only if the Source allows it to be turned off.

 

Why would the Source disallow programmers to use a custom UI?  There could be a multiple of answers for this.  Here are a few:

 

Many of the Source's capability settings are extracted from the settings in the UI only.   This problem occurs if the writer of the Source relied on the UI's edit fields, combo boxes, radio buttons, etc.  as the only place to find many important capability settings.  The writer didn't consider that these settings could have been made programmatically, and not by user intervention.

The writer of the Source can guarantee to get a successful acquisition if the Source UI is enabled, and the non-UI mode has not been tested or is not reliable (this could be related to the first problem).

 

All of the DTWAIN Acquisition functions have a parameter that specifies whether the Source User Interface should be shown.   This parameter will have no effect on Source's that do not allow the User Interface to be hidden.  With newer versions of the TWAIN specification, this problem with inflexible Sources is most likely to be diminished.

 

When acquiring withour a user interface, and you are using DTWAIN notification processing, it is advisable not to show any modal dialog boxes or message boxes during the acquisition of the images.  The reason for this is that the modal dialog/message box may interfere with the TWAIN application loop processing, causing the acquisition to not start or behave erratically.

 

To implement a custom user interface, the application should do the following:

 

Determine if the Source is capable of displaying a custom UI by calling DTWAIN_IsUIControllable.  A TRUE return value indicates that a custom UI is allowed.

 

Implement a user interface that has the most useful capabilities that can be changed. This can include resolution, brightness, gamma control, contrast, and other capabilities that would seem most devices to have.   You may want to implement a 'slider' control for the capabilities that can have many values (brightness and contrast for example), and a more traditional radio button control denoting all of the supported resolutions.  To get the values that these capabilities can have, and to also check if the capabilities are supported, you can use the DTWAIN capability functions.

 

Use the DTWAIN_IsCapSupported function to determine whether a particular capability is supported.  This will allow you to enable/disable controls in your custom interface for a particular Source.

 

Display your custom UI and allow the user to change the capability settings.  When the user selects your 'Ok', 'Go', 'Start' or whatever you used to signal that the acquisition should start, call a DTWAIN acquisition function using a FALSE value for the bShowUI parameter.