How does Simple Scan determine available resolutions?

Asked by Csipak Attila

How does Simple Scan determine available resolutions? Is it a fixed list of values? Is it the result of an autodetection process? In the latter case, which package provides the autodetection mechanism: simple-scan, libsane, sane-utils...?

Question information

Revision history for this message
mycae (mycae) said :
#1

I think you would need to study the simple-scan source code. I had a quick look -- they appear to request the capabilities from the scanner using libsane, and then make a decision based upon this. There is also a number "100" hard-coded as a fallback (not sure) in the source code at one point too.

You can grab a copy of the debian package, which includes code with

sudo apt-get source simple-scan

this will of course be the correct answer -- but otherwise I don't think you will find the internal logic documented anywhere.

Revision history for this message
Csipak Attila (corphicks) said :
#2

Huh, I'm not C expert, otherwise I'd try to fix the related problem on my own (see attached bug). I just wanted to know which package to file the bug on: simple-scan or libsane. I decided for simple-scan, since xsane seems to handle resolutions correctly, so I guess it's not libsane's fault after all.

Revision history for this message
Best Victor Mireyev (victor-mireyev) said :
#3

As I understand, the logic behind resolution control is as following:

1) SimpleScan has a predefined set of resolution values: 75, 150, 300, 600, 1200, 2400 DPI. User selects one of them.

2) Then SimpleScan requests the capabilities from the scanner using libsane. There are 3 possible capabilities: SANE_NAME_SCAN_RESOLUTION, SANE_NAME_SCAN_X_RESOLUTION (the horizontal resolution), SANE_NAME_SCAN_Y_RESOLUTION (the vertical resolution).

As SANE spec states, there are NO mandatory options for resolution control.
Currently SimpleScan uses only the first option, if it's available, of course.

3) Then, SimpleScan tries to find the closest possible match to the user-selected value.
For example, if SANE_NAME_SCAN_RESOLUTION supports values 75 DPI and 200 DPI and user has selected 150 DPI, the real resolution would be 200 DPI.

And if SANE_NAME_SCAN_RESOLUTION supports values 300 DPI and 2400 DPI and user has selected 150 DPI, the real resolution still would be 300 DPI, even if SANE_NAME_SCAN_X_RESOLUTION supports values 300, 2400, 4800 dpi and SANE_NAME_SCAN_Y_RESOLUTION supports values 100, 300, 600 dpi.

Revision history for this message
Csipak Attila (corphicks) said :
#4

Thanks Victor Mireyev, that solved my question.