From dc278c2e9fa65913340c37a26e46f2b52c3e28ba Mon Sep 17 00:00:00 2001 From: "m. allan noah" Date: Mon, 23 Mar 2009 01:04:31 +0000 Subject: [PATCH] * backend/canon_dr.[ch]: backend v19 - pad gray deinterlacing area for DR-2510C - override tl_x and br_x for fixed width scanners * doc/descriptions/canon_dr.desc: backend v19, update comments --- ChangeLog | 6 ++++++ backend/canon_dr.c | 33 +++++++++++++++++++++++++-------- backend/canon_dr.h | 3 ++- doc/descriptions/canon_dr.desc | 4 ++-- 4 files changed, 35 insertions(+), 11 deletions(-) diff --git a/ChangeLog b/ChangeLog index da1993071..15c61d83e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2009-03-22 m. allan noah + * backend/canon_dr.[ch]: backend v19 + - pad gray deinterlacing area for DR-2510C + - override tl_x and br_x for fixed width scanners + * doc/descriptions/canon_dr.desc: backend v19, update comments + 2009-03-21 m. allan noah * backend/canon_dr.[ch], backend/canon_dr-cmd.h: backend v15 thru v18 - add byte-oriented duplex interlace code diff --git a/backend/canon_dr.c b/backend/canon_dr.c index 5988cb56e..9175ad18a 100644 --- a/backend/canon_dr.c +++ b/backend/canon_dr.c @@ -147,6 +147,9 @@ - remove default config file from code - add initial gray deinterlacing code for DR-2510C - rename do_usb_reset to do_usb_clear + v19 2009-03-22, MAN + - pad gray deinterlacing area for DR-2510C + - override tl_x and br_x for fixed width scanners SANE FLOW DIAGRAM @@ -207,7 +210,7 @@ #include "canon_dr.h" #define DEBUG 1 -#define BUILD 18 +#define BUILD 19 /* values for SANE_DEBUG_CANON_DR env var: - errors 5 @@ -1053,6 +1056,7 @@ init_model (struct scanner *s) s->unknown_byte2 = 0x80; s->has_counter = 1; s->head_interlace = HEAD_INTERLACE_2510; + s->fixed_width = 1; } DBG (10, "init_model: finish\n"); @@ -2792,8 +2796,16 @@ sane_get_parameters (SANE_Handle handle, SANE_Parameters * params) /* this backend only sends single frame images */ params->last_frame = 1; - params->pixels_per_line - = s->resolution_x * (s->br_x - s->tl_x) / 1200; + /* dumb scanner, always scans full width */ + /*FIXME: move this elsewhere*/ + if(s->fixed_width){ + s->tl_x = 0; + params->pixels_per_line = s->max_x * s->resolution_x / 1200; + } + else{ + params->pixels_per_line + = (s->br_x - s->tl_x) * s->resolution_x / 1200; + } params->lines = s->resolution_y * (s->br_y - s->tl_y) / 1200; @@ -3069,7 +3081,7 @@ set_window (struct scanner *s) SANE_Status ret = SANE_STATUS_GOOD; /* The command specifies the number of bytes in the data phase - * the data phase has a header, followed by 1 or 2 window desc blocks + * the data phase has a header, followed by 1 window desc block * the header specifies the number of bytes in 1 window desc block */ @@ -3102,13 +3114,13 @@ set_window (struct scanner *s) set_WD_Yres (desc1, s->resolution_y); /* we have to center the window ourselves */ - set_WD_ULX (desc1, s->tl_x + (s->max_x - s->page_width) / 2); - set_WD_ULY (desc1, s->tl_y); + set_WD_ULX (desc1, (s->max_x - s->page_width) / 2 + s->tl_x); /* some models require that the tly value be inverted? */ - if(s->invert_tly){ + if(s->invert_tly) set_WD_ULY (desc1, ~s->tl_y); - } + else + set_WD_ULY (desc1, s->tl_y); set_WD_width (desc1, s->params.pixels_per_line * 1200/s->resolution_x); set_WD_length (desc1, s->params.lines * 1200/s->resolution_y); @@ -3745,6 +3757,11 @@ copy_buffer_2510(struct scanner *s, unsigned char * buf, int len, int side) for(j=0;jbuffers[side][s->bytes_rx[side]++] = buf[i+(twidth-j)*3-2]; } + + /* pad remainder (1/12th) with black */ + for(j=0;jbuffers[side][s->bytes_rx[side]++] = 0; + } } DBG (10, "copy_buffer_2510: finish\n"); diff --git a/backend/canon_dr.h b/backend/canon_dr.h index 8de093261..87713b473 100644 --- a/backend/canon_dr.h +++ b/backend/canon_dr.h @@ -147,7 +147,8 @@ struct scanner int invert_tly; /* weird bug in some smaller scanners */ int unknown_byte; /* weird byte, required, meaning unknown */ int unknown_byte2; /* weird byte, required, meaning unknown */ - size_t status_length; /* usually 4, sometimes 16 */ + size_t status_length; /* usually 4, sometimes 16 */ + int fixed_width; /* sometime machines always scan full width */ int color_interlace; /* different models interlace colors differently */ int duplex_interlace; /* different models interlace sides differently */ diff --git a/doc/descriptions/canon_dr.desc b/doc/descriptions/canon_dr.desc index 2b0371b4f..7424d30d1 100644 --- a/doc/descriptions/canon_dr.desc +++ b/doc/descriptions/canon_dr.desc @@ -11,7 +11,7 @@ :backend "canon_dr" ; name of backend :url "http://www.thebility.com/canon/" -:version "18" ; version of backend +:version "19" ; version of backend :manpage "sane-canon_dr" ; name of manpage (if it exists) :comment "New backend as of SANE release 1.1.0, testers needed, see manpage" :devicetype :scanner ; start of a list of devices.... @@ -81,7 +81,7 @@ :interface "USB" :usbid "0x1083" "0x1617" :status :basic -:comment "Only simplex gray works, requires user to always scan full-width." +:comment "Only simplex gray works, always scans full-width." :model "DR-2580C" :interface "USB SCSI"