[sane-devel] hp5590: Scan aborts when using default page size

Olaf Meeuwissen olaf.meeuwissen at avasys.jp
Sun May 25 23:16:27 UTC 2014


Rainer Keller writes:

> Hi,
>
> when doing a scan from ADF with default page size it will abort with an error:
>
>> scanimage --mode=Color --resolution=300 --source=ADF --verbose >/tmp/foo.pnm   
>> [hp5590] Top Y (0) + pixels Y (106680) exceedes max Y 4200
>> scanimage: sane_start: Invalid argument
>
> After some debugging I could solve this by changing the br_x and br_y default 
> values from millimeters to inches. For me it seems it this is the expected 
> unit for these. It would be nice if someone could confirm this.
>
> Using the attached patch it works:

The SANE API only provides for SANE_UNIT_MM for lengths.  Just looking
at your patch, the *original* code seems to be correct.  The real bug is
somewhere else in the hp5590 backend.

Also, the range_x.max and range_y.max code still convert inches to mm.

>> scanimage --mode=Color --resolution=300 --source=ADF --verbose >/tmp/foo.pnm
>> scanimage: scanning image of size 2550x4200 pixels at 24 bits/pixel
>> scanimage: acquiring RGB frame
>> scanimage: min/max graylevel value = 0/255
>> scanimage: read 32130000 bytes in total
>
> Regards,
>
> Rainer
>
>
> From 392b0e48582338517888153a9ee4a213183c24de Mon Sep 17 00:00:00 2001
> From: Rainer Keller <mail at rainerkeller.de>
> Date: Sat, 24 May 2014 20:15:02 +0200
> Subject: [PATCH] hp5590: br_x and br_y have to be in inches
>
> ---
>  backend/hp5590.c | 12 ++++++------
>  1 file changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/backend/hp5590.c b/backend/hp5590.c
> index 8db3d5e..19c7471 100644
> --- a/backend/hp5590.c
> +++ b/backend/hp5590.c
> @@ -859,14 +859,14 @@ sane_control_option (SANE_Handle handle, SANE_Int 
> option,
>  	      range_x.max = SANE_FIX(scanner->info->max_size_x * 25.4);
>  	      range_y.max = SANE_FIX(ADF_MAX_Y_INCHES * 25.4);
>  	      scanner->br_x = scanner->info->max_size_x;
> -	      scanner->br_y = ADF_MAX_Y_INCHES * 25.4;
> +	      scanner->br_y = ADF_MAX_Y_INCHES;
>  	    }
>  	  if (strcmp ((char *) value, (char *) 
> SANE_VALUE_SCAN_SOURCE_ADF_DUPLEX) == 0)
>  	    {
>  	      scanner->source = SOURCE_ADF_DUPLEX;
>  	      range_x.max = SANE_FIX(scanner->info->max_size_x * 25.4);
>  	      range_y.max = SANE_FIX(ADF_MAX_Y_INCHES * 25.4 * 2);
> -	      scanner->br_y = ADF_MAX_Y_INCHES * 25.4 * 2;
> +	      scanner->br_y = ADF_MAX_Y_INCHES * 2;
>  	      scanner->br_x = scanner->info->max_size_x;
>  	    }
>  	  if (strcmp ((char *) value, (char *) 
> SANE_VALUE_SCAN_SOURCE_TMA_SLIDES) == 0)
> @@ -874,16 +874,16 @@ sane_control_option (SANE_Handle handle, SANE_Int 
> option,
>  	      scanner->source = SOURCE_TMA_SLIDES;
>  	      range_x.max = SANE_FIX(TMA_MAX_X_INCHES * 25.4);
>  	      range_y.max = SANE_FIX(TMA_MAX_Y_INCHES * 25.4);
> -	      scanner->br_x = TMA_MAX_X_INCHES * 25.4;
> -	      scanner->br_y = TMA_MAX_Y_INCHES * 25.4;
> +	      scanner->br_x = TMA_MAX_X_INCHES;
> +	      scanner->br_y = TMA_MAX_Y_INCHES;
>  	    }
>  	  if (strcmp ((char *) value, (char *) 
> SANE_VALUE_SCAN_SOURCE_TMA_NEGATIVES) == 0)
>  	    {
>  	      scanner->source = SOURCE_TMA_NEGATIVES;
>  	      range_x.max = SANE_FIX(TMA_MAX_X_INCHES * 25.4);
>  	      range_y.max = SANE_FIX(TMA_MAX_Y_INCHES * 25.4);
> -	      scanner->br_x = TMA_MAX_X_INCHES * 25.4;
> -	      scanner->br_y = TMA_MAX_Y_INCHES * 25.4;
> +	      scanner->br_x = TMA_MAX_X_INCHES;
> +	      scanner->br_y = TMA_MAX_Y_INCHES;
>  	    }
>  	  if (info)
>  	    *info = SANE_INFO_RELOAD_PARAMS | SANE_INFO_RELOAD_OPTIONS;
> -- 
> 1.8.5.5

Hope this helps,
-- 
Olaf Meeuwissen, LPIC-2           FLOSS Engineer -- AVASYS CORPORATION
FSF Associate Member #1962               Help support software freedom
                 http://www.fsf.org/jf?referrer=1962



More information about the sane-devel mailing list