--1yeeQ81UyVL57Vl7
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

Here is a patch that fixes color scanning on the EPSON Perfection610. It is
based on the epkowa backend (but done in a cleaner way). It works for me -
and most probably does not break anything else. Can people with epson
scanners check it?

Varol Kaptan
va...@cs.ucf.edu

--1yeeQ81UyVL57Vl7
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="perfection610-fix.diff"

--- epson.c.orig        2003-11-04 14:58:39.000000000 -0500
+++ epson.c     2003-11-04 14:59:00.000000000 -0500
@@ -4089,24 +4089,6 @@
        s->params.pixels_per_line = SANE_UNFIX( s->val[ OPT_BR_X].w -  s->val[ 
OPT_TL_X].w) / 25.4 * ndpi + 0.5;
        s->params.lines = SANE_UNFIX( s->val[ OPT_BR_Y].w - s->val[ 
OPT_TL_Y].w) / 25.4 * ndpi + 0.5;
 
-       /* 
-        * Make sure that the number of lines is correct for color shuffling:
-        * The shuffling alghorithm produces 2xline_distance lines at the
-        * beginning and the same amount at the end of the scan that are not
-        * useable. If s->params.lines gets negative, 0 lines are reported
-        * back to the frontend.
-        */
-       if (s->hw->color_shuffle)
-       {
-               s->params.lines -= 4*s->line_distance;
-               if (s->params.lines < 0)
-               {
-                       s->params.lines = 0;
-               }
-               DBG(1, "Adjusted params.lines for color_shuffle by %d to %d\n", 
-                               4*s->line_distance, s->params.lines);
-       }
-
        DBG( 3, "Preview = %d\n", s->val[OPT_PREVIEW].w);
        DBG( 3, "Resolution = %d\n", s->val[OPT_RESOLUTION].w);
 
@@ -4630,41 +4612,18 @@
        s->hw->color_shuffle = SANE_TRUE;
 #endif
 
-
   /* 
    * Modify the scan area: If the scanner requires color shuffling, then we 
try to
    * scan more lines to compensate for the lines that will be removed from the 
scan
    * due to the color shuffling alghorithm.
-   * At this time we add two times the line distance to the number of scan 
lines if
-   * this is possible - if not, then we try to calculate the number of 
additional
-   * lines according to the selected scan area.
+   * At this time we add two times the line distance to the number of scan 
lines.
    */
        if (s->hw->color_shuffle == SANE_TRUE) 
-       {
-
-               /* start the scan 2*line_distance earlier */
-               top -= 2*s->line_distance;
-               if (top < 0)
-               {
-                       top = 0;
-               }
-
-               /* scan 4*line_distance lines more */
-               s->params.lines += 4*s->line_distance;
-       }
-
-       /* 
-        * If (top + s->params.lines) is larger than the max scan area, reset
-        * the number of scan lines:
-        */
-       if (SANE_UNFIX( s->val[ OPT_BR_Y].w) / 25.4 * ndpi < (s->params.lines + 
top))
-       {
-               s->params.lines = ((int) SANE_UNFIX(s->val[OPT_BR_Y].w) / 
-                               25.4 * ndpi + 0.5) - top;
-       }
-
+               s->extra_lines = 2*s->line_distance;
+       else
+               s->extra_lines = 0;
 
-       status = set_scan_area(s, left, top, s->params.pixels_per_line, 
s->params.lines);
+       status = set_scan_area(s, left, top, s->params.pixels_per_line, 
s->params.lines + s->extra_lines);
 
        if( SANE_STATUS_GOOD != status) 
        {
@@ -5045,7 +5004,7 @@
                        if (s->hw->color_shuffle) 
                        {
                                DBG(1, "Written %d lines after color 
shuffle\n", s->lines_written);
-                               DBG(1, "Lines requested: %d\n", 
s->params.lines);
+                               DBG(1, "Lines requested: %d\n", s->params.lines 
+ s->extra_lines);
                        }
 
                        *length = 0;
@@ -5506,6 +5465,7 @@
                        }
 
                        data_ptr += s->params.bytes_per_line;
+                       s->ptr += s->params.bytes_per_line;
 
                        if (s->color_shuffle_line == s->line_distance)
                        {
--- epson.h.orig        2003-11-04 14:58:45.000000000 -0500
+++ epson.h     2003-11-04 15:02:51.000000000 -0500
@@ -271,6 +271,7 @@
        SANE_Option_Descriptor opt [ NUM_OPTIONS];
        Option_Value val [ NUM_OPTIONS];
        SANE_Parameters params;
+       SANE_Int extra_lines;           /* extra lines to read for color 
shuffle */
        SANE_Bool block;
        SANE_Bool eof;
        SANE_Byte * buf, * end, * ptr;

--1yeeQ81UyVL57Vl7--

Reply via email to