<p dir="ltr">I'd recommend taking a glance at the SimpleScan project (<a href="https://github.com/mnagel/simple-scan">https://github.com/mnagel/simple-scan</a>) to get a feel for how commonplace options are handled. </p>
<p dir="ltr">Cheers,<br>
matb</p>
<div class="gmail_quote">On 25 Jun 2015 5:02 am, "Leon Hauck" <<a href="mailto:leon@progcpu.net">leon@progcpu.net</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I'm writing a custom frontend for a scanning project in C++ and am about 80% complete.  I've been able to get this far by reviewing the scanimage and test code included in the source and whatever examples I found on the web.  Hopefully someone can nudge me in the right direction.<br>
<br>
Sane, scanimage, and xsane are configured and running properly on my test system (using an Epson Perfection 636 and a Canon LIDE220).<br>
<br>
In my frontend I've got the device selected and opened and can make repeated scans, however the images I'm saving (in PNM format) aren't what I'm expecting.  I'm pretty sure it's due to not setting some of the options properly prior to the scan.<br>
<br>
So my question is - what settings to I need to set to prior to doing a scan to:<br>
<br>
- set the mode (color or gray)<br>
- set the bit depth of the scan (to largest supported by scanner)<br>
- set the scan area<br>
  (all scans for this application are going to be<br>
   for a fixed area)<br>
<br>
Are there some straight forward examples on how to set these options? I've looked through the scanimage.c code and can't track down exactly where it handles the "--mode Color" command line option.<br>
<br>
The code I'm (unsuccessfully) using now to (attempt to) set these during program startup is below:<br>
<br>
<br>
// ----------------------------------------------------------<br>
// taken from epson sane driver<br>
#define OPT_RESOLUTION 10<br>
#define OPT_TL_X 25<br>
#define OPT_TL_Y 26<br>
#define OPT_BR_X 27<br>
#define OPT_BR_Y 28<br>
#define OPT_MODE 2<br>
#define OPT_BIT_DEPTH 3<br>
<br>
// set photo option<br>
SANE_Int saneIntVal;<br>
<br>
saneIntVal = 300;<br>
sane_control_option( sHand , OPT_RESOLUTION ,<br>
        SANE_ACTION_SET_VALUE , &saneIntVal , &sane_info );<br>
<br>
saneIntVal = 8;<br>
sane_control_option( sHand , OPT_BIT_DEPTH ,<br>
        SANE_ACTION_SET_VALUE , &saneIntVal , &sane_info );<br>
<br>
saneIntVal = 1;<br>
sane_control_option( sHand , OPT_MODE ,<br>
        SANE_ACTION_SET_VALUE , &saneIntVal , &sane_info );<br>
<br>
saneIntVal = 0;<br>
sane_control_option( sHand , OPT_TL_X ,<br>
        SANE_ACTION_SET_VALUE , &saneIntVal , &sane_info );<br>
<br>
saneIntVal = 0;<br>
sane_control_option( sHand , OPT_TL_Y ,<br>
        SANE_ACTION_SET_VALUE , &saneIntVal , &sane_info );<br>
<br>
saneIntVal = 200;<br>
sane_control_option( sHand , OPT_BR_X ,<br>
        SANE_ACTION_SET_VALUE , &  saneIntVal , &sane_info );<br>
<br>
saneIntVal = 200;<br>
sane_control_option( sHand , OPT_BR_Y ,<br>
        SANE_ACTION_SET_VALUE , &saneIntVal , &sane_info );<br>
<br>
<br>
// ----------------------------------------------------------<br>
<br>
<br>
Thanks in advance - any help would be appreciated.<br>
<br>
-- <br>
sane-devel mailing list: <a href="mailto:sane-devel@lists.alioth.debian.org" target="_blank">sane-devel@lists.alioth.debian.org</a><br>
<a href="http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/sane-devel" rel="noreferrer" target="_blank">http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/sane-devel</a><br>
Unsubscribe: Send mail with subject "unsubscribe your_password"<br>
            to <a href="mailto:sane-devel-request@lists.alioth.debian.org" target="_blank">sane-devel-request@lists.alioth.debian.org</a><br>
</blockquote></div>