mirror of
https://github.com/soukoku/ntwain.git
synced 2025-04-05 20:59:23 +08:00
219 lines
17 KiB
HTML
219 lines
17 KiB
HTML
<html>
|
|
|
|
<head>
|
|
<meta http-equiv=Content-Type content="text/html; charset=windows-1252">
|
|
<meta name=Generator content="Microsoft Word 10 (filtered)">
|
|
<title>Correct TWAIN Usage</title>
|
|
|
|
<style>
|
|
<!--
|
|
/* Style Definitions */
|
|
p.MsoNormal, li.MsoNormal, div.MsoNormal
|
|
{margin:0in;
|
|
margin-bottom:.0001pt;
|
|
font-size:12.0pt;
|
|
font-family:"Times New Roman";}
|
|
h1
|
|
{margin-top:6.0pt;
|
|
margin-right:0in;
|
|
margin-bottom:3.0pt;
|
|
margin-left:0in;
|
|
text-align:justify;
|
|
page-break-before:always;
|
|
page-break-after:avoid;
|
|
font-size:18.0pt;
|
|
font-family:"Times New Roman";}
|
|
h2
|
|
{margin-top:6.0pt;
|
|
margin-right:0in;
|
|
margin-bottom:6.0pt;
|
|
margin-left:0in;
|
|
page-break-after:avoid;
|
|
font-size:14.0pt;
|
|
font-family:"Times New Roman";}
|
|
h3
|
|
{margin-top:6.0pt;
|
|
margin-right:0in;
|
|
margin-bottom:3.0pt;
|
|
margin-left:0in;
|
|
page-break-after:avoid;
|
|
font-size:12.0pt;
|
|
font-family:"Times New Roman";}
|
|
h4
|
|
{margin-top:12.0pt;
|
|
margin-right:0in;
|
|
margin-bottom:3.0pt;
|
|
margin-left:0in;
|
|
page-break-after:avoid;
|
|
font-size:14.0pt;
|
|
font-family:"Times New Roman";}
|
|
p.MsoHeader, li.MsoHeader, div.MsoHeader
|
|
{margin:0in;
|
|
margin-bottom:.0001pt;
|
|
font-size:12.0pt;
|
|
font-family:"Times New Roman";}
|
|
p.MsoFooter, li.MsoFooter, div.MsoFooter
|
|
{margin:0in;
|
|
margin-bottom:.0001pt;
|
|
font-size:12.0pt;
|
|
font-family:"Times New Roman";}
|
|
p.MsoBodyText2, li.MsoBodyText2, div.MsoBodyText2
|
|
{margin-top:0in;
|
|
margin-right:0in;
|
|
margin-bottom:6.0pt;
|
|
margin-left:0in;
|
|
line-height:200%;
|
|
font-size:12.0pt;
|
|
font-family:"Times New Roman";}
|
|
p.MsoBodyText3, li.MsoBodyText3, div.MsoBodyText3
|
|
{margin-top:0in;
|
|
margin-right:0in;
|
|
margin-bottom:6.0pt;
|
|
margin-left:0in;
|
|
font-size:8.0pt;
|
|
font-family:"Times New Roman";}
|
|
pre
|
|
{margin:0in;
|
|
margin-bottom:.0001pt;
|
|
font-size:10.0pt;
|
|
font-family:"Courier New";}
|
|
p.style4, li.style4, div.style4
|
|
{margin-top:6.0pt;
|
|
margin-right:0in;
|
|
margin-bottom:3.0pt;
|
|
margin-left:0in;
|
|
text-align:justify;
|
|
page-break-before:always;
|
|
page-break-after:avoid;
|
|
font-size:18.0pt;
|
|
font-family:"Times New Roman";
|
|
font-weight:bold;}
|
|
p.style2, li.style2, div.style2
|
|
{margin-top:6.0pt;
|
|
margin-right:0in;
|
|
margin-bottom:6.0pt;
|
|
margin-left:0in;
|
|
page-break-after:avoid;
|
|
font-size:14.0pt;
|
|
font-family:"Times New Roman";
|
|
font-weight:bold;
|
|
font-style:italic;}
|
|
@page Section1
|
|
{size:8.5in 11.0in;
|
|
margin:1.0in 1.25in 1.0in 1.25in;}
|
|
div.Section1
|
|
{page:Section1;}
|
|
-->
|
|
</style>
|
|
|
|
</head>
|
|
|
|
<body lang=EN-US>
|
|
|
|
<div class=Section1><pre> </pre><pre> </pre><pre><b><span
|
|
style='font-size:12.0pt;font-family:Arial'>Correct TWAIN Usage</span></b></pre><pre><span
|
|
style='font-family:Arial'> </span></pre><pre><span style='font-family:
|
|
Arial'>We recommend against applications identifying scanner models. TWAIN is designed to expose functionality through capability negotiation. Writing applications that use functionality based on a model number makes it harder to maintain the code as new models come out that mix that functionality. For example:</span></pre><pre><span
|
|
style='font-family:Arial'> </span></pre><pre><span style='font-family:
|
|
Arial'> Model 100 has features A, B, C</span></pre><pre><span
|
|
style='font-family:Arial'> Model 200 has features A, X, Y</span></pre><pre><span
|
|
style='font-family:Arial'> </span></pre><pre><span style='font-family:
|
|
Arial'> Code is written as follows:</span></pre><pre><span
|
|
style='font-family:Arial'> Always use A</span></pre><pre><span
|
|
style='font-family:Arial'> If (100) use B, C</span></pre><pre><span
|
|
style='font-family:Arial'> If (200) use X, Y</span></pre><pre><span
|
|
style='font-family:Arial'> </span></pre><pre><span style='font-family:
|
|
Arial'> A new model 300 has features D, C, X</span></pre><pre><span
|
|
style='font-family:Arial'> If (100 200) use A</span></pre><pre><span
|
|
style='font-family:Arial'> If (100) use B, C</span></pre><pre><span
|
|
style='font-family:Arial'> If (200) use X, Y</span></pre><pre><span
|
|
style='font-family:Arial'> If (300) use C, X</span></pre><pre><span
|
|
style='font-family:Arial'> </span></pre><pre><span style='font-family:
|
|
Arial'>There are other ways to code this, but they all get unwieldy over time. The preferred method is:</span></pre><pre><span
|
|
style='font-family:Arial'> </span></pre><pre><span style='font-family:
|
|
Arial'> If A is supported use A</span></pre><pre><span
|
|
style='font-family:Arial'> If B is supported use B</span></pre><pre><span
|
|
style='font-family:Arial'> If C is supported use C</span></pre><pre><span
|
|
style='font-family:Arial'> If X is supported use X</span></pre><pre><span
|
|
style='font-family:Arial'> If Y is supported use Y</span></pre><pre><span
|
|
style='font-family:Arial'> </span></pre><pre><span style='font-family:
|
|
Arial'>In TWAIN a capability is tested for support using DG_CONTROL / DAT_CAPABILITY / MSG_QUERYSUPPORT.</span></pre><pre> </pre><pre> </pre><pre
|
|
style='page-break-before:always'> </pre><pre> </pre><pre><b><span
|
|
style='font-size:12.0pt;font-family:Arial'>Alternative TWAIN Usage</span></b></pre><pre><span
|
|
style='font-family:Arial'> </span></pre><pre><span style='font-family:
|
|
Arial'>Every effort is made to make sure that the standard TWAIN capabilities are presented in a consistent fashion across all scanner models. Unfortunately, this same requirement is harder to enforce for the custom driver features. In situations like this it may be easier to identify a group of functions by associating them with a model number.</span></pre><pre><span
|
|
style='font-family:Arial'> </span></pre><pre><span style='font-family:
|
|
Arial'>Before performing any custom operation an application must unambiguously identify the driver. For all KDS drivers this is done by examining the TW_IDENTITY returned by the DG_CONTROL / DAT_PARENT / MSG_OPENDS, and looking for the following:</span></pre><pre><span
|
|
style='font-family:Arial'> </span></pre><pre><span style='font-family:
|
|
Arial'> Manufacturer "Eastman Kodak Company"</span></pre><pre><span
|
|
style='font-family:Arial'> Version.Info "KDS v#.#.# YYYY/MM/DD"</span></pre><pre><span
|
|
style='font-family:Arial'> </span></pre><pre><span style='font-family:
|
|
Arial'>This information does not apply to the 1500/2500 or the i50/i60/i80. These scanner models use different drivers, so one or both of the above fields will be different.</span></pre><pre><span
|
|
style='font-family:Arial'> </span></pre><pre><span style='font-family:
|
|
Arial'>KDS Version 5/6.x drivers and higher report a specific scanner model through DG_CONTROL / DAT_DEVICEINFO/ MSG_GET when it is called in State 4 or higher. The model information is returned in the TW_DEVICEINFO.dwModelNumber or TW_DEVICEINFO.szModelName field. This is a custom feature of our driver.</span></pre><pre><span
|
|
style='font-family:Arial'> </span></pre><pre><span style='font-family:
|
|
Arial'>KDS Version 4.x drivers and higher report a specific scanner model through DG_CONTROL / DAT_IDENTITY / MSG_GET when it is called in State 4 or higher. The model information is returned in the TW_IDENTITY.ProductName field. This is a custom feature of our driver. </span></pre><pre><span
|
|
style='font-family:Arial'> </span></pre><pre><span style='font-family:
|
|
Arial'>KDS Version 3.x, 2.x and 1.x drivers do not support this feature, so it is necessary to use another method to identify the scanner model. The technique involves the systematic examination of standard and custom capabilities. The pseudo-code for this is provided below.</span></pre><pre><span
|
|
style='font-family:Arial'> </span></pre><pre><span style='font-family:
|
|
Arial'>Note that it is not possible in all situations to uniquely identify all models in this way. However, from the viewpoint of the driver all of the models grouped in a section support exactly the same operations and capabilities, so for the purpose of testing for functionality, this technique is sufficient.</span></pre><pre><span
|
|
style='font-family:Arial'> </span></pre><pre style='page-break-before:
|
|
always'><span style='font-family:Arial'> </span></pre><pre><span
|
|
style='font-family:Arial'> </span></pre><pre><span style='font-family:
|
|
Arial'>if CAP_MODE supported: 5xx/9xx/5xxx/7xxx/9xxx</span></pre><pre><span
|
|
style='font-family:Arial'> if ICAP_FRAMELENGTHCONTROL supported</span></pre><pre><span
|
|
style='font-family:Arial'> if CAP_PRINTERENABLED supported</span></pre><pre><span
|
|
style='font-family:Arial'> if ICAP_XRESOLUTION includes 400 dpi</span></pre><pre><span
|
|
style='font-family:Arial'> 500/7560</span></pre><pre><span
|
|
style='font-family:Arial'> else</span></pre><pre><span
|
|
style='font-family:Arial'> 500A/5520/7520</span></pre><pre><span
|
|
style='font-family:Arial'> endif</span></pre><pre><span
|
|
style='font-family:Arial'> else</span></pre><pre><span
|
|
style='font-family:Arial'> if ICAP_XRESOLUTION includes 400 dpi</span></pre><pre><span
|
|
style='font-family:Arial'> 500/7550</span></pre><pre><span
|
|
style='font-family:Arial'> else</span></pre><pre><span
|
|
style='font-family:Arial'> 500A/5500/7500</span></pre><pre><span
|
|
style='font-family:Arial'> endif</span></pre><pre><span
|
|
style='font-family:Arial'> endif</span></pre><pre><span
|
|
style='font-family:Arial'> else</span></pre><pre><span
|
|
style='font-family:Arial'> if ICAP_XRESOLUTION includes 300</span></pre><pre><span
|
|
style='font-family:Arial'> 900/923/9500/9520</span></pre><pre><span
|
|
style='font-family:Arial'> else</span></pre><pre><span
|
|
style='font-family:Arial'> 990</span></pre><pre><span
|
|
style='font-family:Arial'> endif</span></pre><pre><span
|
|
style='font-family:Arial'> endif</span></pre><pre><span
|
|
style='font-family:Arial'> </span></pre><pre><span style='font-family:
|
|
Arial'>else if CAP_IMAGEADDRESS supported: 8xx</span></pre><pre><span
|
|
style='font-family:Arial'> if ICAP_PIXELTYPE includes TWPT_RGB</span></pre><pre><span
|
|
style='font-family:Arial'> i820/i840</span></pre><pre><span
|
|
style='font-family:Arial'> else</span></pre><pre><span
|
|
style='font-family:Arial'> if ICAP_XRESOLUTION includes 400 dpi</span></pre><pre><span
|
|
style='font-family:Arial'> i830</span></pre><pre><span
|
|
style='font-family:Arial'> else</span></pre><pre><span
|
|
style='font-family:Arial'> i810</span></pre><pre><span
|
|
style='font-family:Arial'> endif</span></pre><pre><span
|
|
style='font-family:Arial'> endif</span></pre><pre><span
|
|
style='font-family:Arial'> </span></pre><pre><span style='font-family:
|
|
Arial'>else it must be mid-volume: 3xxx/4xxx</span></pre><pre><span
|
|
style='font-family:Arial'> if CAP_ENABLECOLORPATCHCODE supported</span></pre><pre><span
|
|
style='font-family:Arial'> 3590</span></pre><pre><span
|
|
style='font-family:Arial'> else if ICAP_PIXELTYPE includes TWPT_RGB</span></pre><pre><span
|
|
style='font-family:Arial'> 4500</span></pre><pre><span
|
|
style='font-family:Arial'> else if CAP_AUTOMATICBORDERDETECTION supported</span></pre><pre><span
|
|
style='font-family:Arial'> 3520</span></pre><pre><span
|
|
style='font-family:Arial'> else if CAP_MULTIFEEDTHICKNESSDETECTION supported</span></pre><pre><span
|
|
style='font-family:Arial'> 3510</span></pre><pre><span
|
|
style='font-family:Arial'> else</span></pre><pre><span
|
|
style='font-family:Arial'> 3500</span></pre><pre><span
|
|
style='font-family:Arial'> endif</span></pre><pre><span
|
|
style='font-family:Arial'> </span></pre><pre><span style='font-family:
|
|
Arial'>endif</span></pre>
|
|
|
|
<p class=MsoNormal><span style='font-family:Arial'> </span></p>
|
|
|
|
</div>
|
|
|
|
</body>
|
|
|
|
</html>
|