[simple-scan/cherry-pick-647d3dea] Improve quality of the Text scans.



commit 64a4d458a78562e2b891f645e45e8a26062a4c56
Author: Bartosz Kosiorek <gang65 poczta onet pl>
Date:   Sun Apr 12 21:28:17 2020 +0000

    Improve quality of the Text scans.
    
    Text scan (Gray) have less information to process, that't why is about 3 times
    faster than color mode. Unfortunately the quality of text scans are not good,
    as it is converted to 2 bit (black and white) images.
    To improve that conversion to black and white images was disabled.
    
    As a result the images have good quality, and the scanning process is fast.
    
    To scan images to black and white, the Lineart mode should be used.
    Unfortunately it is not supported by UX design.
    
    
    (cherry picked from commit 647d3deaeb890e652c48cc7bb25db318b275c314)

 src/app-window.vala |  3 +--
 src/scanner.vala    | 54 -----------------------------------------------------
 2 files changed, 1 insertion(+), 56 deletions(-)
---
diff --git a/src/app-window.vala b/src/app-window.vala
index 446353d..0e25f8d 100644
--- a/src/app-window.vala
+++ b/src/app-window.vala
@@ -919,14 +919,13 @@ public class AppWindow : Gtk.ApplicationWindow
         {
             options.scan_mode = ScanMode.GRAY;
             options.dpi = preferences_dialog.get_text_dpi ();
-            options.depth = 2;
         }
         else
         {
             options.scan_mode = ScanMode.COLOR;
             options.dpi = preferences_dialog.get_photo_dpi ();
-            options.depth = 8;
         }
+        options.depth = 8;
         preferences_dialog.get_paper_size (out options.paper_width, out options.paper_height);
         options.brightness = brightness;
         options.contrast = contrast;
diff --git a/src/scanner.vala b/src/scanner.vala
index 29c729b..67a0d96 100644
--- a/src/scanner.vala
+++ b/src/scanner.vala
@@ -1333,10 +1333,6 @@ public class Scanner : Object
         info.width = parameters.pixels_per_line;
         info.height = parameters.lines;
         info.depth = parameters.depth;
-        /* Reduce bit depth if requested lower than received */
-        // FIXME: This a hack and only works on 8 bit gray to 2 bit gray
-        if (parameters.depth == 8 && parameters.format == Sane.Frame.GRAY && job.depth == 2 && job.scan_mode 
== ScanMode.GRAY)
-            info.depth = job.depth;
         info.n_channels = parameters.format == Sane.Frame.GRAY ? 1 : 3;
         info.dpi = job.dpi; // FIXME: This is the requested DPI, not the actual DPI
         info.device = current_device;
@@ -1476,56 +1472,6 @@ public class Scanner : Object
                 n_used++;
             }
 
-            /* Reduce bit depth if requested lower than received */
-            // FIXME: This a hack and only works on 8 bit gray to 2 bit gray
-            if (parameters.depth == 8 && parameters.format == Sane.Frame.GRAY &&
-                job.depth == 2 && job.scan_mode == ScanMode.GRAY)
-            {
-                uchar block = 0;
-                var write_offset = 0;
-                var block_shift = 6;
-                for (var i = 0; i < line.n_lines; i++)
-                {
-                    var offset = i * line.data_length;
-                    for (var x = 0; x < line.width; x++)
-                    {
-                         var p = line.data[offset + x];
-
-                         uchar sample;
-                         if (p >= 192)
-                             sample = 3;
-                         else if (p >= 128)
-                             sample = 2;
-                         else if (p >= 64)
-                             sample = 1;
-                         else
-                             sample = 0;
-
-                         block |= sample << block_shift;
-                         if (block_shift == 0)
-                         {
-                             line.data[write_offset] = block;
-                             write_offset++;
-                             block = 0;
-                             block_shift = 6;
-                         }
-                         else
-                             block_shift -= 2;
-                    }
-
-                    /* Finish each line on a byte boundary */
-                    if (block_shift != 6)
-                    {
-                        line.data[write_offset] = block;
-                        write_offset++;
-                        block = 0;
-                        block_shift = 6;
-                    }
-                }
-
-                line.data_length = (line.width * 2 + 7) / 8;
-            }
-
             notify_event (new NotifyGotLine (job.id, line));
         }
     }


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