kopia lustrzana https://gitlab.com/sane-project/website
65 wiersze
2.7 KiB
HTML
65 wiersze
2.7 KiB
HTML
|
<html><body>
|
||
|
<a href="doc007.html"><img src=../icons/next.gif alt="Next"></a>
|
||
|
<a href="doc000.html"><img src=../icons/up.gif alt="Up"></a>
|
||
|
<a href="doc005.html"><img src=../icons/previous.gif alt="Previous"></a>
|
||
|
<a href="doc000.html"><img src=../icons/contents.gif alt="Contents"></a>
|
||
|
<hr>
|
||
|
|
||
|
<title>Programming With SANE</title>
|
||
|
<h2><a name="s5">5 Programming With SANE</a></h2>
|
||
|
|
||
|
<p>By definition, SANE is only as good as the programs that use
|
||
|
it. This means the more applications and the more devices that use SANE,
|
||
|
the merrier. The SANE distribution comes with a detailed document
|
||
|
that explains the SANE API; however, the interface is quite simple.
|
||
|
The six main functions are listed below:
|
||
|
|
||
|
<p><blockquote>
|
||
|
<dl>
|
||
|
|
||
|
<p><dt><i>handle</i> <- <tt>sane_open</tt> (<i>device-name</i>):<dd>
|
||
|
allows you to open a SANE device by name (e.g., pnm:0).
|
||
|
|
||
|
<p><dt><tt>sane_close</tt> (<i>handle</i>):<dd> allows you to close a SANE
|
||
|
device.
|
||
|
|
||
|
<p><dt><tt>sane_get_option_descriptor</tt> (<i>handle</i>,
|
||
|
<i>option-number</i>):<dd> is used to query the controls available to
|
||
|
the device (such as the brightness control in the PNM pseudo-device
|
||
|
driver).
|
||
|
|
||
|
<p><dt><tt>sane_control_option</tt> (<i>handle</i>, <i>option-number</i>,
|
||
|
<i>action</i>, <i>value</i>):<dd> is used to get or set the value of an
|
||
|
option. For example, it can be used to set the value of the
|
||
|
brightness option to 50 percent. In addition, some options support
|
||
|
an auto-mode where the driver picks a reasonable value. For such
|
||
|
options, <tt>sane_control_option()</tt> can also be used to turn
|
||
|
auto-mode on or off.
|
||
|
|
||
|
<p><dt><tt>sane_start</tt> (<i>handle</i>):<dd> is used to start the
|
||
|
acquisition of an image.
|
||
|
|
||
|
<p><dt><i>bytes-read</i> <- <tt>sane_read</tt> (<i>handle</i>,
|
||
|
<i>buffer</i>, <i>buffer-size</i>):<dd> is used to read the actual image
|
||
|
data until the entire image has been acquired.
|
||
|
|
||
|
<p></dl>
|
||
|
</blockquote>
|
||
|
|
||
|
<p>The SANE API is simple by design. The goal was to make it possible to
|
||
|
accomplish a simple task in a small amount of time while still
|
||
|
providing enough functionality to enable sophisticated drivers and
|
||
|
applications. The simplicity is best evidenced by the fact that it
|
||
|
took just two evening sessions to convert the <tt>hpscanpbm</tt> program
|
||
|
into a SANE driver for HP scanners. On the other end of the spectrum,
|
||
|
the Mustek driver and xscanimage are fairly complicated programs and
|
||
|
SANE had no problems accommodating them.
|
||
|
|
||
|
<p><p><hr>
|
||
|
<a href="doc007.html"><img src=../icons/next.gif alt="Next"></a>
|
||
|
<a href="doc000.html"><img src=../icons/up.gif alt="Up"></a>
|
||
|
<a href="doc005.html"><img src=../icons/previous.gif alt="Previous"></a>
|
||
|
<a href="doc000.html"><img src=../icons/contents.gif alt="Contents"></a>
|
||
|
<hr>
|
||
|
</body></html>
|