This project has moved. For the latest updates, please go here.

limit scanner settings and abort operation

Apr 27, 2016 at 5:09 PM
My implementations set DPI and allow users to tweak settings (feeder, orientation...) in scanner dependent settings dialog by manufacturer.
_twain.ShowUI = true;
_twain.Capabilities.XResolution.Set(300f);
_twain.Capabilities.PixelType.Set(TwPixelType.BW);
However, I don't want users to change DPI or Color options. Is it possible?

If not, can the scanning operation be aborted by my codes in EndXfer event when I first know the scanning settings are not what I want?
Coordinator
Apr 28, 2016 at 7:27 PM
Hello, tochi.
The possibility restrict the available values of capability is exist, but only if it is supported by the scanner.

DG_CONTROL / DAT_CAPABILITY / MSG_SETCONSTRAINT

Description

Changes the Current Value(s) and Available Value(s) of the specified capability to those specified by the application.
Current Values are set when the container is a TW_ONEVALUE or TW_ARRAY. Available and Current Values are set when the container is a TW_ENUMERATION, TW_ARRAY or TW_RANGE.
Note: Sources are not required to allow restriction of their Available Values, however, this is strongly recommended.

Application

An application will use the setting of a capability’s Available Values when the Source was enabled (DG_CONTROL / DAT_USERINTERFACE / MSG_ENABLEDS) with TW_USERINTERFACE.ShowUI = TRUE.
Set the Current Value(s) to be displayed to the user as the current value. This value will be used for acquiring the image unless changed by the user or an automatic process (such as ICAP_AUTOBRIGHT).
Set the Available Values to restrict the settings displayed to the user and available for use by the Source.

TWAIN 2.2 Specification 7-35


In a latest source code I added a Twain32.SetConstraintCap and ICapability<T>.SetConstraint methods
if(this._twain32.Capabilities.PixelType.IsSupported(TwQC.SetConstraint)) {
    this._twain32.Capabilities.PixelType.SetConstraint(TwPixelType.BW);
}
The scanning operation cannot be aborted in EndXfer event.
However, the most reliable way will be not to use the scanner UI.
Marked as answer by SARAFF on 5/1/2016 at 1:04 AM
Nov 9, 2016 at 1:08 PM
Edited Nov 9, 2016 at 1:08 PM
Can you tell us How can I Set the Available Values to restrict the settings displayed to the user and available for use by the Source.

I am aware of Setting current value but don't how to set available value. Thanks!
Nov 9, 2016 at 1:10 PM
Can you tell us How can I Set the Available Values to restrict the settings displayed to the user and available for use by the Source.

I am aware of Setting current value but don't how to set available value. Thanks!
Coordinator
Nov 10, 2016 at 6:35 AM
Hello, gajendra20.
Follow code as sample:
if(_twain32.Capabilities.PixelType.IsSupported(TwQC.SetConstraint)) {
    _twain32.Capabilities.PixelType.SetConstraint(TwPixelType.BW, TwPixelType.Gray);
}