

1.如何获取黑白图像/span>
DWObject.OpenSource();DWObject.IfShowUI = false;DWObject.IfDisableSourceAfterAcquire = true;DWObject.PixelType = EnumDWT_PixelType.TWPT_BW; //Black - Whiteimage : EnumDWT_PixelType.TWPT_BW, GRAY image:EnumDWT_PixelType.TWPT_GRAY, RGBimage: EnumDWT_PixelType.TWPT_RGBDWObject.AcquireImage();
2.如何在没有用户界面的情况下运行/span>
function BeginScan(){ DWObject.OpenSource(); DWObject.IfShowUI = false; //set without user interface DWObject.IfDisableSourceAfterAcquire = true; DWObject.AcquireImage();}function DWObject_OnPostTransfer(){ DWObject.SaveAsBMP("C:\temp.bmp",0);}
3.如何只扫描纸张的某一部分/span>
DWObject.SelectSource();DWObject.OpenSource();DWObject.IfShowUI = false;//Set Image LayoutDWObject.Unit = EnumDWT_UnitType.TWUN_INCHES;DWObject.SetImageLayout(0, 0, 5, 5);DWObject.AcquireImage();
4.如何在不显示设备选择对话框的情况下选择设备/span>
DWObject.OpenSourceManager();for(i = 0, i<=DWObject.SourceCount - 1,i++){ if (DWObject.GetSourceNameItems(i) == "Specified device name") DWObject.SelectSourceByIndex (i);}//if can't find the specified source, it'll select default sourceDWObject.AcquireImage();
5.如何在不使用UI获取图像时禁用进度指示器对话框/span>
DWObject.IfShowUI = false;DWObject.IfDisableSourceAfterAcquire = true;DWObject.OpenSource();DWObject.IfShowIndicator = false;DWObject.AcquireImage();
6.如何分别设置水平和垂直分辨率/span>
DWObject.SelectSource();DWObject.OpenSource();//Set XRESOLUTION current value.DWObject.Capability = 0x1118; //ICAP_XRESOLUTIONDWObject.CapType = 5; //TWON_ONEVALUEDWObject.CapValue = 300;if (DWObject.CapSet == false){ alert( "Failed to set the x-resolution. " + DWObject.ErrorString);}//Set YRESOLUTION current value.DWObject.Capability = 0x1119; //ICAP_YRESOLUTIONDWObject.CapType = 5; //TWON_ONEVALUEDWObject.CapValue = 200;if (DWObject.CapSet == false){ alert( "Failed to set the y-resolution." + DWObject.ErrorString);}DWObject.AcquireImage();
7.如何上传到Web服务器/span>
DWObject = document.getElementById("dwtcontrolContainer");//dwtcontrolContainer is the id of the Dynamic Web TWAIN on the page (An object or an embed).function btnScan_onclick(){DWObject.SelectSource();DWObject.OpenSource();DWObject.AcquireImage();}function btnUpload_onclick(){var strActionPage;var strHostIP;var CurrentPathName = unescape(location.pathname); // get current PathName inplain ASCIIvar CurrentPath = CurrentPathName.substring(0, CurrentPathName.lastIndexOf("/")+ 1);strActionPage = CurrentPath + "SaveToFile.aspx"; //the ActionPage's file pathstrHostIP = "localhost"; //The host's IP or nameDWObject.HTTPPort = 80;DWObject.HTTPUploadThroughPost(strHostIP,0,strActionPage,"imageData.tif");if (DWObject.ErrorCode != 0)alert(DWObject.ErrorString);else //succeedalert("Image Uploaded successfully");}
8.如何使用ADF望将每个文档保存在一个单独的文件中。
var iDocumentCounter =0;function BeginScan(){ DWObject.OpenSource(); DWObject.IfShowUI = false; DWObject.IfDisableSourceAfterAcquire = true; if(DWObject.Duplex != TWDX_NONE) DWObject.IfDuplexEnabled = true; //enable duplexDWObject.IfFeederEnabled = true; if (DWObject.IfFeederEnabled == true){ DWObject.XferCount = -1; if(DWObject.IfFeederLoaded == True) DWObject.AcquireImage(); }}function DWObject_OnPosttransfer(){iDocumentCounter = iDocumentCounter + 1;if(DWObject.SaveAsBMP("C:\Image\" + iDocumentCounter + ".bmp", 0) == false) alert( DWObject.ErrorString);}
9.我如何使用SSL/span>
您可以使用IfSSL属性。下面的JavaScript示例将显示如何使用IfSSL属性。
function btnUpload_onclick(){ DWObject.HTTPPort = 80; DWObject.IfSSL = false; // if 80 is the port number ofnon-secure port /* DWObject.HTTPPort = 443; DWObject.IfSSL = true; // if 443 is the port number of secureport */ DWObject.HTTPUploadThroughPost("127.0.0.1", 0,"/SaveToFile.php", "imageData.jpg"); if (DWObject.ErrorCode != 0) alert(DWObject.ErrorString); else //succeed alert("Successful");}
10.如何将新扫描的图像添加到现有的多页TIFF文件中/span>
function Scan_Click(){ DWObject.AcquireImage();}function DWObject_OnPostTransfer(){ DWObject.CloseSource(); DWObject.IfTiffMultiPage = true; DWObject.SaveAsTIFF("SaveAsTIFF.tif", 0); if (DWObject.ErrorCode != 0) alert (DWObject.ErrorString); else //succeed alert ("Successful");}
11.如何在保存之前旋转图像/span>
您可以使用RotateLeft方法和RotateRight方法。
12.如果缓冲区中有多个图像,如何查看指定的图像/span>
您可以通过更新API CurrentImageIndexInBuffer的值来查看指定的图像或浏览缓冲区中的所有图像。
function NextImage_Click(){ if (DWObject.HowManyImagesInBuffer == 0) alert ("There is no image in buffer"); DWObject.CurrentImageIndexInBuffer += 1;}13.如何进行双面扫描unction DuplexScan_Click(){ DWObject.SelectSource(); DWObject.OpenSource(); DWObject.IfShowUI = false; DWObject.IfDuplexEnabled = true; //enable duplex DWObject.AcquireImage();}
14.如何以反转颜色扫描图像/span>
您可以使用PixelFlavor属性。
2017十四周年狂欢搞事情!砸金蛋100%抽现金红包、满额豪送iPhone X、iPhone 8、DevExpress汉化免费送、团队升级培训套包劲省10万元……更多惊喜等您来探索!
标签:扫描识别扫描与图像
声明:本站部分文章及图片源自用户投稿,如本站任何资料有侵权请您尽早请联系jinwei@zod.com.cn进行处理,非常感谢!