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

m. allan noah kitno455 at gmail.com
Wed Jun 24 19:12:50 UTC 2015


are you honoring the value which is returned in sane_info?

allan

On Wed, Jun 24, 2015 at 2:55 PM, 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



-- 
"well, I stand up next to a mountain- and I chop it down with the edge
of my hand"



More information about the sane-devel mailing list