[sane-devel] Scanning Lineart/Halftone with MICROTEK Scanmak

Oliver Rauch oliver.rauch at rauch-domain.de
Sun May 26 21:17:59 BST 2002


Hello Michael,

there still is another bug in the same routine with the variable x.
This variable has to be global because it is not allowed
to reinitiate the value each time when  xsane_read_image_data()
is called. .... will be fixed in xsane-0.87

Bye
Oliver

mh wrote:
> 
> Oliver Rauch, Sonntag, 26. Mai 2002 16:57:
> > mh wrote:
> > > after I could not find a bug in my backend, I dared to take a look at
> > > xsane. I'm quite sure now, that there's indeed a bug in xsane. Please
> > > take a look at the attached patch for xsane_scan.c.
> > > I've tested this with the tevion, pnm and the test backend -> no
> > > problems.
> >
> > Very strange. Your patch makes sense but I do not understand why it does
> > work without the patch with the pnm backend.
> >
> > I have a more simple patch, please can you test it:
> >
> > -- fwrite(expanded_buf8, 1, len*8, xsane.out);
> > ++ fwrite(expanded_buf8, 1, (size_t) (expanded_buf8ptr - expanded_buf8),
> > xsane.out);
> 
> That works...
> This is really a strange bug, but there's one difference between the pnm
> backend and e.g. the tevion backend:
> When you "scan" a lineart image with the pnm backend, sane_read will allways
> return the number of bytes requested by the frontend (or the number of bytes
> left in the input file). This is normally more than one scanline, because
> xsane probably request 32 kB or something.
> With the tevion backend (and probably other backends too), sane_read can
> return a number of bytes smaller or equal to the size of one scanline.
> You can now modify the pnm backend in a way, that it returns one byte per
> call to sane_read, and voila, suddenly the bug also occurrs with the pnm
> backend :-)
> This also reveals a small bug in the pnm backend, which will cause the
> frontend to hang in some rare cases.
> See pnm.c around line 1162:
> 
> /* Suck in as much of the file as possible, since it's already in the
>    correct format. */
>   len = fread (data, 1, max_length, infile);
> 
> If fread returns 0, then *length is set to 0 and SANE_STATUS_GOOD is returned.
> The frontend therefore expects more data, and calls sane_read again... ->
> infinite loop
> 
> We should replace this with
> 
> {
>   /* Suck in as much of the file as possible, since it's already in the
>      correct format. */
>   len = fread (data, 1, max_length, infile);
>   if(len <= 0)
>     return SANE_STATUS_EOF;
> }
> 
> If you want to reproduce the xsane bug with the pnm backend, just replace
> max_length with 1.
> 
> bb
> Michael
> 
> _______________________________________________
> Sane-devel mailing list
> Sane-devel at www.mostang.com
> http://www.mostang.com/mailman/listinfo/sane-devel

-- 
Homepage:	http://www.rauch-domain.de
sane-umax:	http://www.rauch-domain.de/sane-umax
xsane:		http://www.xsane.org
E-Mail:		mailto:Oliver.Rauch at rauch-domain.de



More information about the sane-devel mailing list