[patch] Re: sane-0.57 available

David Mosberger-Tang (davidm@azstarnet.com)
Wed, 14 May 1997 09:16:08 -0700

>>>>> On Wed, 14 May 1997 10:54:55 +0200 (MET DST), Matthias Lautner <l=
autner@hoggle.syscomp.de> said:

Matthias> Hi! I tested sane-0.57 on my MFS-12000CX 3-pass scanner
Matthias> and got errors while scanning color images with gamma
Matthias> table allthough the scanned image looks good.

I don't see off-hand what's going wrong (and am a bit short of time).
The red/green/blue gamma tables should not be set at all for 3-pass
scanners (each pass, a (different) gray-scale gamma table should be
down-loaded only). Can you investigate? For debugging purposes, it's
recommended to run configure with --disable-shared.

Matthias> The progress bar of xscanimage stops at each scan after
Matthias> about 90% and proceeds to 100% on the next pass

Hmmh, the next pass should use a _new_ progress bar. Is that not
what's happening?

Matthias> Halftone scanning with xscanimage: pattern size 0 works
Matthias> good. In all other cases the Pattern box has only a
Matthias> horizontal Line. How can I set the patterns. xscanimage
Matthias> offers only a curve to alter like gamma correction.

Yeah, I'm not sure I really care about the half-tone pattern. If
somebody knows how it's being used and what it's useful for, they can
feel free to make it work. I'm sure there are some cases where this
would be useful, but I haven't had any need for halftone scanning with
customized half-tone pattern. I suspect what we'd need to support
this properly is a "matrix" data type.

Matthias> The brightness and contrast is calculated wrong for 3-pass
Matthias> mustek scanners. change in function encode_percentage()
Matthias> in mustek.c code =3D (int) ((value / 100.0 / quant) + 0.5) =
+
Matthias> 0x0c; to code =3D (int) (((value +100) / 100.0 * 12.0) +
Matthias> 0.5); // quant is now unused

Oh, there was indeed a bug in there. I the patch below should make
it work correctly (at least according to my docs).

Matthias> In color scanning the previous settings of brightness and
Matthias> contrast from a former Lineart scan are used and take
Matthias> effect. Why shouldn=B4t it be allowed to set brightness
Matthias> and contrast in color mode?

At least for single-pass scanners those controls have absolutely no
effect in color mode (I confirmed this with Mustek). If you tell me
that they work in color-mode for 3-pass scanners, just let me know and
I'll enable them for those scanners.

Oh, would you mind telling me what the label on the front of your
scanner is? The firmware revision would be useful as well (see output
of "SANE_DEBUG_MUSTEK=3D2 scanimage -d mustek -h >/dev/null").

=09--david

--- mustek.c~=09Sat May 10 15:05:11 1997
+++ mustek.c=09Wed May 14 08:53:49 1997
@@ -57,49 +57,65 @@
static Mustek_Scanner *first_handle;
=20
static const SANE_String_Const mode_list[] =3D
-{
- "Lineart", "Halftone", "Gray",
- "Color Lineart", "Color Halftone", "Color",
- 0
-};
+ {
+ "Lineart", "Halftone", "Gray",
+ "Color Lineart", "Color Halftone", "Color",
+ 0
+ };
=20
static const SANE_String_Const speed_list[] =3D
-{
- "Slowest", "Slower", "Normal", "Faster", "Fastest",
- 0
-};
+ {
+ "Slowest", "Slower", "Normal", "Faster", "Fastest",
+ 0
+ };
=20
static const SANE_String_Const source_list[] =3D
-{
- "Flatbed", "Automatic Document Feeder", "Transparency Adapter",
- 0
-};
+ {
+ "Flatbed", "Automatic Document Feeder", "Transparency Adapter",
+ 0
+ };
=20
static const SANE_Int grain_list[] =3D
-{
- 6,=09=09=09=09/* # of elements */
- 2, 3, 4, 5, 6, 8
-};
+ {
+ 6,=09=09=09=09/* # of elements */
+ 2, 3, 4, 5, 6, 8
+ };
=20
static const SANE_Range u8_range =3D
-{
- 0,=09=09=09=09/* minimum */
- 255,=09=09=09=09/* maximum */
- 0=09=09=09=09/* quantization */
-};
+ {
+ 0,=09=09=09=09/* minimum */
+ 255,=09=09=09=09/* maximum */
+ 0=09=09=09=09/* quantization */
+ };
=20
static const SANE_Int pattern_dimension_list[] =3D
-{
- 8,=09=09=09=09/* # of elements */
- 0, 2, 3, 4, 5, 6, 7, 8
-};
+ {
+ 8,=09=09=09=09/* # of elements */
+ 0, 2, 3, 4, 5, 6, 7, 8
+ };
=20
static const SANE_Range percentage_range =3D
-{
- -100 << SANE_FIXED_SCALE_SHIFT,=09/* minimum */
- 100 << SANE_FIXED_SCALE_SHIFT,=09/* maximum */
- 1 << SANE_FIXED_SCALE_SHIFT=09/* quantization */
-};
+ {
+ -100 << SANE_FIXED_SCALE_SHIFT,=09/* minimum */
+ 100 << SANE_FIXED_SCALE_SHIFT,=09/* maximum */
+ 1 << SANE_FIXED_SCALE_SHIFT=09/* quantization */
+ };
+
+/* for three-pass (ax) scanners: */
+
+static const SANE_Range ax_brightness_range =3D
+ {
+ -36 << SANE_FIXED_SCALE_SHIFT,=09/* minimum */
+ 36 << SANE_FIXED_SCALE_SHIFT,=09/* maximum */
+ 3 << SANE_FIXED_SCALE_SHIFT=09/* quantization */
+ };
+
+static const SANE_Range ax_contrast_range =3D
+ {
+ -84 << SANE_FIXED_SCALE_SHIFT,=09/* minimum */
+ 84 << SANE_FIXED_SCALE_SHIFT,=09/* maximum */
+ 7 << SANE_FIXED_SCALE_SHIFT=09/* quantization */
+ };
=20
/* Color band codes: */
#define MUSTEK_CODE_GRAY=09=090
@@ -523,7 +539,7 @@
}
else
{
- code =3D (int) ((value / 100.0 / quant) + 0.5) + 0x0c;
+ code =3D (int) ((value / quant) + 0.5) + 0x0c;
max =3D 0x18;
}
if (code > max)
@@ -1188,7 +1204,10 @@
s->opt[OPT_BRIGHTNESS].cap |=3D SANE_CAP_INACTIVE;
s->opt[OPT_BRIGHTNESS].unit =3D SANE_UNIT_PERCENT;
s->opt[OPT_BRIGHTNESS].constraint_type =3D SANE_CONSTRAINT_RANGE;
- s->opt[OPT_BRIGHTNESS].constraint.range =3D &percentage_range;
+ if (s->hw->flags & MUSTEK_FLAG_SINGLE_PASS)
+ s->opt[OPT_BRIGHTNESS].constraint.range =3D &percentage_range;
+ else
+ s->opt[OPT_BRIGHTNESS].constraint.range =3D &ax_brightness_range;
s->val[OPT_BRIGHTNESS].w =3D 0;
=20
/* contrast */
@@ -1201,7 +1220,10 @@
s->opt[OPT_CONTRAST].cap |=3D SANE_CAP_INACTIVE;
s->opt[OPT_CONTRAST].unit =3D SANE_UNIT_PERCENT;
s->opt[OPT_CONTRAST].constraint_type =3D SANE_CONSTRAINT_RANGE;
- s->opt[OPT_CONTRAST].constraint.range =3D &percentage_range;
+ if (s->hw->flags & MUSTEK_FLAG_SINGLE_PASS)
+ s->opt[OPT_CONTRAST].constraint.range =3D &percentage_range;
+ else
+ s->opt[OPT_CONTRAST].constraint.range =3D &ax_contrast_range;
s->val[OPT_CONTRAST].w =3D 0;
=20
/* custom-gamma table */

--
Source code, list archive, and docs: http://www.azstarnet.com/~axplinux/sane/
To unsubscribe: mail -s unsubscribe sane-devel-request@listserv.azstarnet.com