[sane-devel] scanimage bug?

Major A andras@users.sourceforge.net
Mon, 29 Apr 2002 03:36:48 +0100


> I see. I don't like counting starting by 0 :-)
> This seems to be only relevant for SANE_TYPE_INT. What about this one:
> 
> Index: frontend/scanimage.c
> ===================================================================
> RCS file: /cvsroot/external/sane/sane-backends/frontend/scanimage.c,v
> retrieving revision 1.25
> diff -u -u -r1.25 scanimage.c
> --- scanimage.c	2002/04/27 09:40:21	1.25
> +++ scanimage.c	2002/04/27 21:03:30
> @@ -390,8 +390,13 @@
>  	case SANE_CONSTRAINT_RANGE:
>  	  if (opt->type == SANE_TYPE_INT)
>  	    {
> -	      printf ("%d..%d",
> -		      opt->constraint.range->min, opt->constraint.range->max);
> +	      if (opt_num == window[0] || opt_num == window[1])
> +		/* width and height */
> +		printf ("%d..%d", opt->constraint.range->min,
> +			opt->constraint.range->max + 1);
> +	      else
> +		printf ("%d..%d", opt->constraint.range->min,
> +			opt->constraint.range->max);
>  	      print_unit (opt->unit);
>  	      if (opt->size > (SANE_Int) sizeof (SANE_Word))
>  		fputs (",...", stdout);
> @@ -457,7 +462,10 @@
>  	      break;

Looks good so far, but seems to be rather a dirty hack... also, as you
mentioned, this only works for quant=1.

>  	    case SANE_TYPE_INT:
> -	      printf ("%d", *(SANE_Int *) val);
> +	      if (opt_num == window[0] || opt_num == window[1])
> +		printf ("%d", (*(SANE_Int *) val) + 1);
> +	      else
> +		printf ("%d", *(SANE_Int *) val);
>  	      break;
>  
>  	    case SANE_TYPE_FIXED:

I don't think this is right. The whole point is that the range given
by scanimage -h differs from what it will eventually accept. For 1000
CCD pixels, I can give a width of 1000 (and it will scan 1000) even
though scanimage -h says 0..999 for both left and width.

> It fixes only the range.max value and doesn't try to force 1 for
> range.min. In reality, this should be something like:
> 
> range.min = 1;
> range.max = br_x.range.max - tl_x.range.min + 1;
> 
> Correct? Can be more difficult if range.quant != 1 ...

Exactly.

  Andras

===========================================================================
Major Andras
    e-mail: andras@users.sourceforge.net
    www:    http://andras.webhop.org/
===========================================================================