Leon Hauck writes: > 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.
Have a look at the SANE API specification as well. It's at http://www.sane-project.org/html/ > Sane, scanimage, and xsane are configured and running properly on my > test system (using an Epson Perfection 636 and a Canon LIDE220). 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. > 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. You also want to check the SANE_Parameters you get back from sane_get_parameters() *after* you have called sane_start(). > So my question is - what settings to I need to set to prior to doing a > scan to: The answer to which is "It depends". The SANE API does not require backends to provide any particular settings in any particular way. A backend is even at liberty to provide different lists of settings for different scanners. > - 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 scanimage program doesn't handle the --mode option. It is provided by the backend for the scanner that you selected. Run `scanimage -h` without scanners attached to get the list of options that are provided by scanimage itself. > 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 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). > // 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 ); The epson backend expects a string for its mode setting. > 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. Hope this helps, -- Olaf Meeuwissen, LPIC-2 FLOSS Engineer -- AVASYS CORPORATION FSF Associate Member #1962 Help support software freedom http://www.fsf.org/jf?referrer=1962 -- sane-devel mailing list: sane-devel@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-requ...@lists.alioth.debian.org