View on GitHub

SARAFF SOFTWARE

All products / Saraff.Twain.NET / Contents

General (not strongly typed) accessing to a capabilities

This way is versatile and can be used for any capabilities. Following methods of a Twain32 class, provide necessary functionality

//Brightness
if((this._twain32.IsCapSupported(TwCap.Brightness)&TwQC.Set)!=0) {
    this._twain32.SetCap(TwCap.Brightness,100f); //Allowed Values: -1000f to +1000f; Default Value: 0f;
}
//Contrast
if((this._twain32.IsCapSupported(TwCap.Contrast)&TwQC.Set)!=0) {
    this._twain32.SetCap(TwCap.Contrast,-150f); //Allowed Values: -1000f to +1000f; Default Value: 0f;
}
//Feeder & Duplex
if((this._twain32.IsCapSupported(TwCap.Duplex)&TwQC.GetCurrent)!=0) {
    var _duplexCapValue=(TwDX)this._twain32.GetCurrentCap(TwCap.Duplex);
    if(_duplexCapValue!=TwDX.None) {
        if((this._twain32.IsCapSupported(TwCap.FeederEnabled)&TwQC.Set)!=0) {
            this._twain32.SetCap(TwCap.FeederEnabled,true);

            if((this._twain32.IsCapSupported(TwCap.DuplexEnabled)&TwQC.Set)!=0) {
                this._twain32.SetCap(TwCap.DuplexEnabled,true);
            }
            this._twain32.SetCap(TwCap.XferCount,(short)-1);
        }
    }
}

Very important to correctly identify the type of value.