简体   繁体   中英

How to modify resolution (DPI) Range in TWAIN User Interface (DS)

I would like set DPI range in Twain Scanner User Interface. Have a look at below Screenshot. The DPI drop down start from 50 to 600.How can I restrict this from 400 to 600.

在此输入图像描述

I have tried the following code but it just sets the DPI, if user changes from user interface my changes goes away.

            TwFix32 f32 = new TwFix32();
            f32.FromFloat(400);//value of DPI 
            TwCapability capX = new TwCapability(TwCap.XResolution, f32.Whole);
            rc = dScap(appid, srcds, TwDG.Control, TwDAT.Capability, TwMSG.Set, capX);

            TwCapability capY= new TwCapability(TwCap.YResolution, f32T.Whole);
            rc = dScap(appid, srcds, TwDG.Control, TwDAT.Capability, TwMSG.Set, capY);

Every TWAIN source implements its own user interface. The TWAIN specification does not provide a method for changing this user interface; you can only display it.

The best you can do is to write your own UI and display that instead of asking TWAIN to display its UI. You can then interrogate the device to determine which resolutions it supports, and filter out any options which don't meet your needs. You can programmatically set the DPI (as you're already doing) immediately prior to image acquisition.

To change the Image resolution

 this._twain32.Capabilities.XResolution.Set((float)_item.Tag);
 this._twain32.Capabilities.YResolution.Set((float)_item.Tag);

To select the Flatbed type scanner,

if (this._twain32.Capabilities.Duplex.IsSupported(TwQC.GetCurrent) && this._twain32.Capabilities.Duplex.GetCurrent() != TwDX.None)
                {
                    if (this._twain32.Capabilities.FeederEnabled.IsSupported(TwQC.Set))
                    {
                        this._twain32.Capabilities.FeederEnabled.Set(false);

                        if (this._twain32.Capabilities.DuplexEnabled.IsSupported(TwQC.Set))
                        {
                            this._twain32.Capabilities.DuplexEnabled.Set(false);
                        }
                        this._twain32.Capabilities.XferCount.Set(1);
                    }
                }

To select ADF type scanner,

if (this._twain32.Capabilities.Duplex.IsSupported(TwQC.GetCurrent) && this._twain32.Capabilities.Duplex.GetCurrent() != TwDX.None)
                {
                    if (this._twain32.Capabilities.FeederEnabled.IsSupported(TwQC.Set))
                    {
                        this._twain32.Capabilities.FeederEnabled.Set(true);

                        if (this._twain32.Capabilities.DuplexEnabled.IsSupported(TwQC.Set))
                        {
                            this._twain32.Capabilities.DuplexEnabled.Set(true);
                        }
                        this._twain32.Capabilities.XferCount.Set(-1);
                    }
                }

Above code is using the Saraff.Twain( free ) dll as a reference.

I know its old questions but this would help someone who is new to TWAIN.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM