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

set brightness and contrast

Feb 6, 2014 at 1:41 PM
Hello Saraff!

I'm using your api for my scan application. Can you help me, how can I set brightness and contrast before I scan the document?

Feb 7, 2014 at 6:15 PM
Edited Feb 7, 2014 at 6:18 PM
Hello, stefiboy.
Use follow code:
if((this._twain32.IsCapSupported(TwCap.Brightness)&TwQC.Set)!=0) {
    this._twain32.SetCap(TwCap.Brightness,1000f); /* Allowed Values: -1000f to 1000f; Default Value: 0f; */
if((this._twain32.IsCapSupported(TwCap.Contrast)&TwQC.Set)!=0) {
    this._twain32.SetCap(TwCap.Contrast,-1000f); /* Allowed Values: -1000f to 1000f; Default Value: 0f; */
Marked as answer by SARAFF on 6/23/2014 at 12:34 PM
Feb 8, 2014 at 2:51 PM
Hello Saraff!
Thank you for your quick help!
I didn't find free twain.dll, which I can use on 32bit and 64bit operation system, therefore I use your dll.
I have looked your source code. Am I interpret well that you used original twain.dll to create your own dll?

Feb 8, 2014 at 3:37 PM
Hello, stefiboy.
Yes. Saraff.Twain.dll uses directly twain_32.dll (in accordance with the specification TWAIN 1.9).
Mar 26, 2014 at 12:51 AM
Hello Saraff!
I have to create a list of not wia supported connected scanner devices which . It's easy, because there's a 'WIA' word in WIA device's name.
But there are scanners in the list, which are not connected to the computer, only installed their driver's. Now I can test the valid connected devices with this code:
   //TWAIN init
        _twain32 = new SaraffTwain.Twain32();
        _twain32.TwainStateChanged += new EventHandler<DexTwain.Twain32.TwainStateEventArgs>(_twain_TwainStateChanged);
        _twain32.ShowUI = false;
        _twain32.AcquireCompleted += new EventHandler(_twain32_AcquireComplete);
        _twain32.EndXfer += new EventHandler<DexTwain.Twain32.EndXferEventArgs>(_twain32_EndXfer); 
        for (int i = 0; i < _twain32.SourcesCount; i++)
                                _twain32.SourceIndex = i;       
                                if (!_twain32.GetSourceProductName(i).Contains("WIA") )
                                        if (_twain32.OpenDataSource())

                                    catch (TwainException tex) {
But when I call OpendataSource at not connected device, the device's twain software shows an error message! It's normal, but I'd like to skip it.
Do yo think there is any way to test the connection of the device? (without calling opendatasource )
Mar 26, 2014 at 5:07 PM
Hello, stefiboy.
No other way (at least, I don't know about it).
Apr 30, 2015 at 11:57 PM
I see AutoBright how come there is no AutoContrast?
//Set AutoBright
if ((twain32.IsCapSupported(TwCap.AutoBright) & TwQC.Set) != 0)
   twain32.SetCap(TwCap.AutoBright, true);

//No AutoContrast?
if ((twain32.IsCapSupported(TwCap.AutoContrast) & TwQC.Set) != 0)
    twain32.SetCap(TwCap.AutoContrast, true);
May 1, 2015 at 12:03 PM
Hello, javamike.
The AutoContrast don't exist. See TWAIN Specification.
May 5, 2015 at 6:22 PM
Thank you, Saraff.