[sane-devel] Setting Options Via sane_control_option(...)

Matthew Baker mu.beta.06 at gmail.com
Fri Jun 26 00:34:16 UTC 2015


I'd recommend taking a glance at the SimpleScan project (
https://github.com/mnagel/simple-scan) to get a feel for how commonplace
options are handled.

Cheers,
matb
On 25 Jun 2015 5:02 am, "Leon Hauck" <leon at progcpu.net> wrote:

> 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.
>
> Sane, scanimage, and xsane are configured and running properly on my test
> system (using an Epson Perfection 636 and a Canon LIDE220).
>
> 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.
>
> So my question is - what settings to I need to set to prior to doing a
> scan to:
>
> - set the mode (color or gray)
> - set the bit depth of the scan (to largest supported by scanner)
> - set the scan area
>   (all scans for this application are going to be
>    for a fixed area)
>
> 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.
>
> The code I'm (unsuccessfully) using now to (attempt to) set these during
> program startup is below:
>
>
> // ----------------------------------------------------------
> // taken from epson sane driver
> #define OPT_RESOLUTION 10
> #define OPT_TL_X 25
> #define OPT_TL_Y 26
> #define OPT_BR_X 27
> #define OPT_BR_Y 28
> #define OPT_MODE 2
> #define OPT_BIT_DEPTH 3
>
> // set photo option
> SANE_Int saneIntVal;
>
> saneIntVal = 300;
> sane_control_option( sHand , OPT_RESOLUTION ,
>         SANE_ACTION_SET_VALUE , &saneIntVal , &sane_info );
>
> saneIntVal = 8;
> sane_control_option( sHand , OPT_BIT_DEPTH ,
>         SANE_ACTION_SET_VALUE , &saneIntVal , &sane_info );
>
> saneIntVal = 1;
> sane_control_option( sHand , OPT_MODE ,
>         SANE_ACTION_SET_VALUE , &saneIntVal , &sane_info );
>
> saneIntVal = 0;
> sane_control_option( sHand , OPT_TL_X ,
>         SANE_ACTION_SET_VALUE , &saneIntVal , &sane_info );
>
> saneIntVal = 0;
> sane_control_option( sHand , OPT_TL_Y ,
>         SANE_ACTION_SET_VALUE , &saneIntVal , &sane_info );
>
> saneIntVal = 200;
> sane_control_option( sHand , OPT_BR_X ,
>         SANE_ACTION_SET_VALUE , &  saneIntVal , &sane_info );
>
> saneIntVal = 200;
> sane_control_option( sHand , OPT_BR_Y ,
>         SANE_ACTION_SET_VALUE , &saneIntVal , &sane_info );
>
>
> // ----------------------------------------------------------
>
>
> Thanks in advance - any help would be appreciated.
>
> --
> sane-devel mailing list: sane-devel at lists.alioth.debian.org
> http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/sane-devel
> Unsubscribe: Send mail with subject "unsubscribe your_password"
>             to sane-devel-request at lists.alioth.debian.org
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.alioth.debian.org/pipermail/sane-devel/attachments/20150626/83103f3f/attachment.html>


More information about the sane-devel mailing list