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

Leon Hauck leon at progcpu.net
Mon Jun 29 23:16:10 UTC 2015

On 06/25/2015 05:27 PM, Olaf Meeuwissen wrote:

> Have a look at the SANE API specification as well.  It's at
>    http://www.sane-project.org/html/

Thanks for reminding me.  I came across that years ago when I was first 
looking at using sane, and for some reason I didn't notice that before I 
started this project.

> Can your custom project assume that only these scanner will ever be
> used?  If yes, you can get away with much more hard-coding than you
> would be able to do with a more generic SANE frontend.

I had originally planned on hard-coding the options, but as part of my 
debugging I'm now running through all the backend options via 
sane_get_option_descriptor and setting them appropriately.

> You are aware of the fact that these values differ between backends,
> right?  You should use sane_get_option_descriptor() and iterate over the
> options are see if any corresponds to one of the well-known options for
>    resolution
>    tl-x
>    tl-y
>    br-x
>    br-y
> There are no well-known options for mode and (bit-)depth, bummer.
> See http://www.sane-project.org/html/doc014.html for a list
> Once you've found the options of interest, you can set values of the
> correct type and that satisfy the option's constraint (if any).
> Hope this helps,

This pointed me down the right path.  I was able to correct my problems by:

- using SANE_FIX() macro to properly get the coordinate options mapped 
to the correct variable type.

- realizing that the epson2 backend I was using took a character string 
to set the scanning mode ("Color") instead of a numeric option.

Once I've got the project up and running I'm going to publish the code - 
hopefully someone will find the examples useful.

Thanks again...

-- Leon

More information about the sane-devel mailing list