在 div dwtcontrolContainer 动态 Web TWAIN SDK API 中定义 ImageSize

Define ImageSize in div dwtcontrolContainer Dynamic Web TWAIN SDK APIs

如何在dwtcontrolContainerdiv中调整扫描图像的大小?因为当我向下滚动屏幕时,selected 区域永远不会跟随鼠标,select 鼠标点击上方的区域。

下面是我的 AcquireImage 函数:

function AcquireImage() {
            try {
                if (DWObject) {
                    var _obj = {};
                    _obj.IfShowUI = false;
                    _obj.PixelType = 0;
                    _obj.Resolution = 300;
                    _obj.IfFeederEnabled = true;
                    _obj.IfDuplexEnabled = false;
                    _obj.IfDisableSourceAfterAcquire = true; // Scanner source will be disabled/closed automatically after the scan.
                    _obj.Brightness = 10000;
                    _obj.MaxImagesInBuffer = 3;
                    _obj.PageSize = 0;
                    _obj.Contrast = 1000;

                    DWObject.SelectSourceByIndex(document.getElementById("rdlScanner").selectedIndex);
                    DWObject.OpenSource();
                    DWObject.AcquireImage(_obj);
                    DWObject.SetViewMode(-1, -1);

                    DWObject.CurrentImageIndexInBuffer = 0;

                    updatePageInfo();
                }

            }
            catch (err) {
                alert("Error: " + err.message);
            }
        }

我发现 http://developer.dynamsoft.com/dwt/dynamic-web-twain-how-to-resize-the-viewer-automatically 但即使配置 .js dynamsoft.webtwain.config.js 也不起作用

您的 link 是关于如何更改查看器的大小,而不是图像大小。我在这里将您的查看器大小更改为 600x800:

function AcquireImage() {
            try {
                if (DWObject) {
                    DWObject.Width = 600; // viewer width
                    DWObject.Height = 800; // viewer height
                    var _obj = {};
                    _obj.IfShowUI = false;
                    _obj.PixelType = 0;
                    _obj.Resolution = 300;
                    _obj.IfFeederEnabled = true;
                    _obj.IfDuplexEnabled = false;
                    _obj.IfDisableSourceAfterAcquire = true; // Scanner source will be disabled/closed automatically after the scan.
                    _obj.Brightness = 10000;
                    _obj.MaxImagesInBuffer = 3;
                    _obj.PageSize = 0;
                    _obj.Contrast = 1000;

                    DWObject.SelectSourceByIndex(document.getElementById("rdlScanner").selectedIndex);
                    DWObject.OpenSource();
                    DWObject.AcquireImage(_obj);
                    DWObject.SetViewMode(-1, -1);

                    DWObject.CurrentImageIndexInBuffer = 0;

                    updatePageInfo();
                }

            }
            catch (err) {
                alert("Error: " + err.message);
            }
        }

如果您想更改图像大小,请访问此 link:http://developer.dynamsoft.com/dwt/changeimagesize

我创建了两个按钮来更改图像大小:

function small() {
        var DWObject = Dynamsoft.WebTwainEnv.GetWebTwain('dwtcontrolContainer');
        DWObject.ChangeImageSize(0, 300, 400, EnumDWT_InterpolationMethod.IM_NEARESTNEIGHBOUR);
    }
    function big() {
        var DWObject = Dynamsoft.WebTwainEnv.GetWebTwain('dwtcontrolContainer');
        DWObject.ChangeImageSize(0, 600, 800, EnumDWT_InterpolationMethod.IM_NEARESTNEIGHBOUR);
    }