简体   繁体   English

如何在TWAIN用户界面(DS)中修改分辨率(DPI)范围

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

I would like set DPI range in Twain Scanner User Interface. 我想在Twain扫描仪用户界面中设置DPI范围。 Have a look at below Screenshot. 看看下面的截图。 The DPI drop down start from 50 to 600.How can I restrict this from 400 to 600. DPI下降从50开始到600.如何将此限制从400到600。

在此输入图像描述

I have tried the following code but it just sets the DPI, if user changes from user interface my changes goes away. 我尝试了以下代码,但它只设置了DPI,如果用户从用户界面更改,我的更改就会消失。

            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. 每个TWAIN源都实现自己的用户界面。 The TWAIN specification does not provide a method for changing this user interface; TWAIN规范没有提供更改此用户界面的方法; 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. 您可以做的最好的事情是编写自己的UI并显示 UI 而不是要求TWAIN显示其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. 您可以在图像采集之前立即以编程方式设置DPI(正如您已经在做的那样)。

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, 要选择ADF型扫描仪,

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. 上面的代码使用Saraff.Twain(免费)dll作为参考。

I know its old questions but this would help someone who is new to TWAIN. 我知道它的旧问题,但这可以帮助TWAIN新手。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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