[simple-scan] Fix automatic size detection on Brother scanners



commit e23c1cf338e1f4496aebe773b1489acb3d2481b1
Author: Bartosz Kosiorek <gang65 poczta onet pl>
Date:   Wed Sep 22 16:56:13 2021 +0200

    Fix automatic size detection on Brother scanners
    
    Fixes #264

 data/logs/Brother_MFC-J4340DW.log | 78 +++++++++++++++++++++++++++++++++++++++
 src/scanner.vala                  | 12 ++++--
 2 files changed, 87 insertions(+), 3 deletions(-)
---
diff --git a/data/logs/Brother_MFC-J4340DW.log b/data/logs/Brother_MFC-J4340DW.log
new file mode 100644
index 00000000..a22bdfad
--- /dev/null
+++ b/data/logs/Brother_MFC-J4340DW.log
@@ -0,0 +1,78 @@
+[+0.00s] DEBUG: simple-scan.vala:2014: Starting simple-scan 40.1, PID=136048
+[+0.00s] DEBUG: unsetenv() is not thread-safe and should not be used after threads are created
+[+0.08s] DEBUG: app-window.vala:1982: Restoring window to 1350x926 pixels
+[+0.09s] DEBUG: scanner.vala:1590: sane_init () -> SANE_STATUS_GOOD
+[+0.09s] DEBUG: scanner.vala:1596: SANE version 1.0.32
+[+0.09s] DEBUG: scanner.vala:1657: Requesting redetection of scan devices
+[+0.09s] DEBUG: scanner.vala:844: Processing request
+[+0.27s] DEBUG: app-window.vala:2078: Saving state to [...]
+[+2.11s] DEBUG: scanner.vala:348: sane_get_devices () -> SANE_STATUS_GOOD
+[+2.11s] DEBUG: scanner.vala:360: Device: name="brother5:bus1;dev2" vendor="Brother" model="MFC-J4340DW" 
type="USB scanner"
+[+25.28s] DEBUG: simple-scan.vala:1819: Requesting scan at 300 dpi from device 'brother5:bus1;dev2'
+[+25.28s] DEBUG: scanner.vala:1748: Scanner.scan ("brother5:bus1;dev2", dpi=300, scan_mode=ScanMode.COLOR, 
depth=8, type=adf, side=both, paper_width=2100, paper_height=2970, brightness=0, contrast=0, delay=0ms)
+[+25.28s] DEBUG: scanner.vala:844: Processing request
+[+25.45s] DEBUG: scanner.vala:905: sane_open ("brother5:bus1;dev2") -> SANE_STATUS_GOOD
+[+25.45s] DEBUG: scanner.vala:982: sane_get_option_descriptor (0)
+[+25.45s] DEBUG: scanner.vala:776: Option 0: name='(null)' title='Number of options' type=bool size=4 
cap=soft-detect
+[+25.45s] DEBUG: scanner.vala:779:   Description: Read-only option that specifies how many options a 
specific devices supports.
+[+25.45s] DEBUG: scanner.vala:982: sane_get_option_descriptor (1)
+[+25.45s] DEBUG: scanner.vala:776: Option 1: name='(null)' type=group size=4 cap=advanced
+[+25.45s] DEBUG: scanner.vala:779:   Description: 
+[+25.45s] DEBUG: scanner.vala:982: sane_get_option_descriptor (2)
+[+25.45s] DEBUG: scanner.vala:776: Option 2: name='mode' title='Scan mode' type=string size=30 
values=["24bit Color[Fast]", "Black & White", "True Gray", "Gray[Error Diffusion]"] 
cap=soft-select,soft-detect
+[+25.45s] DEBUG: scanner.vala:779:   Description: Select the scan mode
+[+25.45s] DEBUG: scanner.vala:982: sane_get_option_descriptor (3)
+[+25.45s] DEBUG: scanner.vala:776: Option 3: name='resolution' title='Scan resolution' type=int size=4 
unit=dpi values=[100, 150, 200, 300, 400, 600, 1200, 2400, 4800, 9600] cap=soft-select,soft-detect
+[+25.45s] DEBUG: scanner.vala:779:   Description: Sets the resolution of the scanned image.
+[+25.45s] DEBUG: scanner.vala:982: sane_get_option_descriptor (4)
+[+25.45s] DEBUG: scanner.vala:776: Option 4: name='source' title='Scan source' type=string size=64 
values=["FlatBed", "Automatic Document Feeder(left aligned)", "Automatic Document Feeder(center aligned)"] 
cap=soft-select,soft-detect
+[+25.45s] DEBUG: scanner.vala:779:   Description: Selects the scan source (such as a document-feeder).
+[+25.45s] DEBUG: scanner.vala:982: sane_get_option_descriptor (5)
+[+25.45s] DEBUG: scanner.vala:776: Option 5: name='brightness' title='Brightness' type=fixed size=4 
unit=percent min=-50.000000, max=50.000000, quant=65536 cap=soft-select,soft-detect,inactive
+[+25.45s] DEBUG: scanner.vala:779:   Description: Controls the brightness of the acquired image.
+[+25.45s] DEBUG: scanner.vala:982: sane_get_option_descriptor (6)
+[+25.45s] DEBUG: scanner.vala:776: Option 6: name='contrast' title='Contrast' type=fixed size=4 unit=percent 
min=-50.000000, max=50.000000, quant=65536 cap=soft-select,soft-detect,inactive
+[+25.45s] DEBUG: scanner.vala:779:   Description: Controls the contrast of the acquired image.
+[+25.45s] DEBUG: scanner.vala:982: sane_get_option_descriptor (7)
+[+25.45s] DEBUG: scanner.vala:776: Option 7: name='MultifeedDetection' title='Multifeed Detection' type=bool 
size=4 cap=soft-select,soft-detect,inactive,advanced
+[+25.45s] DEBUG: scanner.vala:779:   Description: 
+[+25.45s] DEBUG: scanner.vala:982: sane_get_option_descriptor (8)
+[+25.45s] DEBUG: scanner.vala:776: Option 8: name='AutoDocumentSize' title='Auto Document Size' type=bool 
size=4 cap=soft-select,soft-detect,advanced
+[+25.45s] DEBUG: scanner.vala:779:   Description: 
+[+25.45s] DEBUG: scanner.vala:982: sane_get_option_descriptor (9)
+[+25.45s] DEBUG: scanner.vala:776: Option 9: name='AutoDeskew' title='Auto Deskew' type=bool size=4 
cap=soft-select,soft-detect,advanced
+[+25.45s] DEBUG: scanner.vala:779:   Description: 
+[+25.45s] DEBUG: scanner.vala:982: sane_get_option_descriptor (10)
+[+25.45s] DEBUG: scanner.vala:776: Option 10: name='SkipBlankPage' title='Skip Blank Page' type=bool size=4 
cap=soft-select,soft-detect,advanced
+[+25.45s] DEBUG: scanner.vala:779:   Description: 
+[+25.45s] DEBUG: scanner.vala:982: sane_get_option_descriptor (11)
+[+25.45s] DEBUG: scanner.vala:776: Option 11: name='SkipBlankPageSensitivity' title='Skip Blank Page 
sensitivity' type=fixed size=4 unit=percent min=0.000000, max=100.000000, quant=65536 
cap=soft-select,soft-detect,advanced
+[+25.45s] DEBUG: scanner.vala:779:   Description: 
+[+25.45s] DEBUG: scanner.vala:982: sane_get_option_descriptor (12)
+[+25.45s] DEBUG: scanner.vala:776: Option 12: name='(null)' title='Geometry' type=group size=4 
cap=soft-select,soft-detect
+[+25.45s] DEBUG: scanner.vala:779:   Description: 
+[+25.45s] DEBUG: scanner.vala:982: sane_get_option_descriptor (13)
+[+25.45s] DEBUG: scanner.vala:776: Option 13: name='tl-x' title='Top-left x' type=fixed size=4 unit=mm 
min=0.000000, max=215.899994, quant=6553 cap=soft-select,soft-detect
+[+25.45s] DEBUG: scanner.vala:779:   Description: Top-left x position of scan area.
+[+25.45s] DEBUG: scanner.vala:982: sane_get_option_descriptor (14)
+[+25.45s] DEBUG: scanner.vala:776: Option 14: name='tl-y' title='Top-left y' type=fixed size=4 unit=mm 
min=0.000000, max=355.599991, quant=6553 cap=soft-select,soft-detect
+[+25.45s] DEBUG: scanner.vala:779:   Description: Top-left y position of scan area.
+[+25.45s] DEBUG: scanner.vala:982: sane_get_option_descriptor (15)
+[+25.45s] DEBUG: scanner.vala:776: Option 15: name='br-x' title='Bottom-right x' type=fixed size=4 unit=mm 
min=0.000000, max=215.899994, quant=6553 cap=soft-select,soft-detect
+[+25.45s] DEBUG: scanner.vala:779:   Description: Bottom-right x position of scan area.
+[+25.45s] DEBUG: scanner.vala:982: sane_get_option_descriptor (16)
+[+25.45s] DEBUG: scanner.vala:776: Option 16: name='br-y' title='Bottom-right y' type=fixed size=4 unit=mm 
min=0.000000, max=355.599991, quant=6553 cap=soft-select,soft-detect
+[+25.45s] DEBUG: scanner.vala:779:   Description: Bottom-right y position of scan area.
+[+25.45s] DEBUG: scanner.vala:982: sane_get_option_descriptor (17)
+[+25.45s] DEBUG: scanner.vala:583: sane_control_option (4, SANE_ACTION_SET_VALUE, source="Automatic Document 
Feeder(left aligned)") -> (SANE_STATUS_GOOD, "Automatic Document Feeder(left aligned)")
+[+25.45s] DEBUG: scanner.vala:583: sane_control_option (2, SANE_ACTION_SET_VALUE, mode="24bit Color[Fast]") 
-> (SANE_STATUS_GOOD, "24bit Color[Fast]")
+[+25.45s] DEBUG: scanner.vala:495: sane_control_option (3, SANE_ACTION_SET_VALUE, resolution=300) -> 
(SANE_STATUS_GOOD, 300)
+[+25.45s] DEBUG: scanner.vala:535: sane_control_option (15, SANE_ACTION_SET_VALUE, br-x=210.000000) -> 
(SANE_STATUS_GOOD, 209.980774)
+[+25.45s] DEBUG: scanner.vala:535: sane_control_option (16, SANE_ACTION_SET_VALUE, br-y=297.000000) -> 
(SANE_STATUS_GOOD, 296.972809)
+[+25.45s] WARNING: scanner.vala:1286: The option brightness (5) is inactive and can't be set, please file a 
bug
+[+25.45s] WARNING: scanner.vala:1286: The option contrast (6) is inactive and can't be set, please file a bug
+[+36.37s] DEBUG: scanner.vala:1322: sane_start (page=0, pass=0) -> SANE_STATUS_GOOD
+[+36.37s] DEBUG: scanner.vala:1359: sane_get_parameters () -> SANE_STATUS_GOOD
+[+36.37s] DEBUG: scanner.vala:1371: Parameters: format=SANE_FRAME_RGB last_frame=SANE_TRUE 
bytes_per_line=7404 pixels_per_line=2468 lines=3496 depth=8
+[+36.37s] DEBUG: scanner.vala:1446: sane_read (7405) -> (SANE_STATUS_GOOD, 7404)
+[+36.37s] DEBUG: simple-scan.vala:1714: Page is 2468 pixels wide, 3496 pixels high, 8 bits per pixel
diff --git a/src/scanner.vala b/src/scanner.vala
index 745b7798..01e77e2f 100644
--- a/src/scanner.vala
+++ b/src/scanner.vala
@@ -925,8 +925,8 @@ public class Scanner : Object
             "Automatic Document Feeder",
             Sane.I18N ("Automatic Document Feeder"),
             "ADF",
-            "Automatic Document Feeder(left aligned)", /* Seen in the proprietary brother3 driver */
             "Automatic Document Feeder(centrally aligned)", /* Seen in the proprietary brother3 driver */
+            "Automatic Document Feeder(left aligned)", /* Seen in the proprietary brother3 driver */
             "ADF Simplex" /* Samsung unified driver. LP: # 892915 */
         };
 
@@ -1140,7 +1140,7 @@ public class Scanner : Object
                 set_fixed_or_int_option (handle, option, index, job.dpi, out job.dpi);
                 option = get_option_by_name (handle, Sane.NAME_SCAN_Y_RESOLUTION, out index);
             }
-             else
+            else
                 option = get_option_by_name (handle, Sane.NAME_SCAN_RESOLUTION, out index);
             if (option == null) /* #161 Lexmark CX310dn Duplex */
                 option = get_option_by_name (handle, "scan-resolution", out index);
@@ -1172,11 +1172,17 @@ public class Scanner : Object
                 else
                     set_option_to_max (handle, option, index);
             }
-            if (job.page_width == 0) /* #90 Fix automatic mode for Epson scanners */
+            if (job.page_width == 0)
             {
+                /* #90 Fix automatic mode for Epson scanners */
                 option = get_option_by_name (handle, "scan-area", out index);
                 if (option != null)
                     set_string_option (handle, option, index, "Maximum", null);
+
+                /* #264 Enable automatic document size for Brother scanners */
+                option = get_option_by_name (handle, "AutoDocumentSize", out index);
+                if (option != null)
+                    set_bool_option (handle, option, index, true, null);
             }
             /* Set page size */
             option = get_option_by_name (handle, Sane.NAME_PAGE_WIDTH, out index);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]