--FL5UXtIhxfXey3p5 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline
Here is a good patch (I did an extensive set of tests to make sure it is working as intended) Varol On Tue, Nov 04, 2003 at 03:47:43PM -0500, k...@khk.net wrote: > You basically disabled the error checks for a negative number of > scan lines and the case where more scan lines as the scanner can support > are requested. This is not acceptable - the checks are there for > a reason. You are certainly free to use a modified backend with > your scanner, but I will not apply your patch to the CVS version. > > Karl Heinz --FL5UXtIhxfXey3p5 Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="perfection610-fix1.diff" --- epson.c.orig 2003-11-04 17:07:40.000000000 -0500 +++ epson.c 2003-11-04 19:39:08.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,35 @@ 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; - } + s->extra_lines = 2*s->line_distance; + else + s->extra_lines = 0; /* - * If (top + s->params.lines) is larger than the max scan area, reset - * the number of scan lines: + * If (top + s->params.lines + s->extra_lines) is larger than the max scan + * area, adjust 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; - } + SANE_Int cur_br_y, max_br_y; + max_br_y = (SANE_Int) (SANE_UNFIX(s->hw->y_range->max) / 25.4 * ndpi + 0.5); + cur_br_y = top + s->params.lines + s->extra_lines; + + if (max_br_y < cur_br_y) + { + s->params.lines = (max_br_y - s->extra_lines) - top; + DBG( 5, "sane_start: adjusting lines to %d\n", s->params.lines); + } + } - 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 +5021,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 +5482,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 17:07:43.000000000 -0500 +++ epson.h 2003-11-04 18:02:15.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; --FL5UXtIhxfXey3p5--