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

时间:2017-11-17 15:26:48

标签: javascript dynamic-web-twain

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

Bellow是我的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也不起作用

1 个答案:

答案 0 :(得分:2)

您的链接是关于如何更改查看器的大小,而不是图像大小。在这里,我将您的观看者尺寸更改为 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);
            }
        }

如果您想更改图片尺寸,请访问以下链接: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);
    }

enter image description here