ThierryHFR / libmfp2-canon

Sane backend 'canon_pixma' for CANON's scanners
GNU General Public License v2.0
1 stars 0 forks source link

Setting scanner parameters #4

Closed gregbath closed 5 years ago

gregbath commented 5 years ago

When I used 'scanimage -A' I got the following parameters reported for my TS8260.

All options specific to device `canon_pixma:9C-32-CE-D9-95-3C': Scan Mode: --mode Color|Gray [Color] Selects the scan mode (e.g., lineart, monochrome, or color). --resolution 75|100|150|200|300dpi [300] Sets the resolution of the scanned image. --preview[=(yes|no)] [no] Request a preview-quality scan. Geometry: -l 0..0.00457764pel (in steps of 1.52588e-05) [0] Top-left x position of scan area. -t 0..0.00457764pel (in steps of 1.52588e-05) [0] Top-left y position of scan area. -x 0..0.00457764pel (in steps of 1.52588e-05) [0.0378418] Width of scan-area. -y 0..0.00457764pel (in steps of 1.52588e-05) [0.0535126] Height of scan-area.

When I compared this to the eSCL interface output (from a simple python script I found) that showed my mfp supports 2 other resolutions 600 and 1200. Also the geometry does not appear to be reporting correctly and I do not seem to be able to change it. Preview mode also does not work.

I had a look at canon_pixma.c and found 2 things that looked strange to me. Actually it all looked very strange as it is about 30 years since I last did any C coding and then only very limited stuff and I am struggling to understand the sane-backend interface.

At line 760 onward: handled->val[n].w = (SANE_Word ) v; if(i && handled->val[n].w != (SANE_Word ) v){ i |= SANE_INFO_RELOAD_PARAMS | SANE_INFO_RELOAD_OPTIONS | SANE_INFO_INEXACT; } handled->val[n].w = (SANE_Word *) v;

The first line appears to be in error. It prevents the if statement from executing and is repeated immediately below it anyway.

Also at line 769 onward: if(v1 > 100){ handled->sgmp.scan_source = CIJSC_SOURCE_DOCUMENT; } else{ handled->sgmp.scan_source = CIJSC_SOURCE_PHOTO; }

I would have thought that if test is the wrong way around. Resolutions greater than 100 would be image and less documents.

Also I do not understand the setting of the scan ranges at line 528 (x_range.max = data->scan_res;) and line 532 (y_range.max = data->scan_res;). I would have thought this should be set to the scanner maximums (for my scanner at least of) 2550 and 3508.

eSCL_ScannerCapabilities.txt

Or if you have one that is network connected and supports eSCL use your browser http://your_scanner_ip_address/eSCL/ScannerCapabilities

ThierryHFR commented 5 years ago

scangearmp2 has some of its code close. The binary only offers two modes: document and photo. There is no preview mode. It was a devinatte game to implement it. I am ready to push your changes in the backend that I propose. Sangearmp2#7

kno10 commented 5 years ago

For preview, you'd likely just scan with a low resolution.

Instead of relying on this low-quality closed-source library, it may be a better idea to implement the (XML and HTTP based!) eSCL-protocol.

I have done a proof-of-concept in Python 2 a while ago (and I actually still use this for scanning): https://github.com/kno10/python-scan-eSCL/blob/master/scan.py This allows me to scan with higher resolution than with the official Canon tool (although first it didn't work on the first attempt, retrying eventually helped; there seems to be a state issue that if the scanner is in a confused state, it will fail the next scan; but once you have working parameters these will work).

By now, there are also first efforts to make an eSCL backend for sane: https://gitlab.com/sane-escl/sane-escl

ThierryHFR commented 5 years ago

I do not understand your request. The project has this address (https://gitlab.com/sane-escl/sane-escl). Is the one I put up with a trainee. There will probably be more development on libmfp2-canon and scangearmp2.