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

set brightness and contrast

Feb 6, 2014 at 12: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?

Thanks
Coordinator
Feb 7, 2014 at 5:15 PM
Edited Feb 7, 2014 at 5:18 PM
Hello, stefiboy.
Use follow code:
this._twain32.OpenDataSource();
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; */
}
this._twain32.Acquire();
Marked as answer by SARAFF on 6/23/2014 at 12:34 PM
Feb 8, 2014 at 1: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?

Thanks
Stefiboy
Coordinator
Feb 8, 2014 at 2:37 PM
Hello, stefiboy.
Yes. Saraff.Twain.dll uses directly twain_32.dll (in accordance with the specification TWAIN 1.9).
Mar 25, 2014 at 11:51 PM
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.OpenDSM();
        _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") )
                                {
                                    try
                                    {
                                        if (_twain32.OpenDataSource())
                                        {
                                            comboBox_devices.Items.Add(_twain32.GetSourceProductName(i));                                             
                                            _twain32.CloseDataSource()
                                        }

                                    }
                                    catch (TwainException tex) {
                                        _twain32.CloseDataSource();
                                    }
                          }
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 )
Coordinator
Mar 26, 2014 at 4:07 PM
Hello, stefiboy.
No other way (at least, I don't know about it).
Apr 30, 2015 at 10: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);
Coordinator
May 1, 2015 at 11:03 AM
Hello, javamike.
The AutoContrast don't exist. See TWAIN Specification.
May 5, 2015 at 5:22 PM
Thank you, Saraff.