kopia lustrzana https://gitlab.com/sane-project/backends
Added new test backend.
Henning Meier-Geinitz <henning@meier-geinitz.de>DEVEL_2_0_BRANCH-1
rodzic
506d04e2fe
commit
798ff200da
|
@ -63,8 +63,9 @@ PRELOADABLE_BACKENDS = abaton agfafocus apple artec as6e avision bh canon \
|
|||
canon630u @CANON_PP@ coolscan dc25 @DC210@ @DC240@ dmc epson \
|
||||
@GPHOTO2@ hp m3096g matsushita microtek microtek2 mustek mustek_pp \
|
||||
mustek_usb nec @NET@ pie @PINT@ plustek @PNM@ @QCAM@ ricoh s9036 \
|
||||
sceptre sharp @SM3600@ @SNAPSCAN@ sp15c st400 tamarack teco1 umax \
|
||||
umax_pp umax1220u @V4L@
|
||||
sceptre sharp @SM3600@ @SNAPSCAN@ sp15c st400 tamarack test \
|
||||
teco1 umax umax_pp umax1220u @V4L@
|
||||
|
||||
ALL_BACKENDS = $(PRELOADABLE_BACKENDS) dll
|
||||
|
||||
LIBS = $(addprefix libsane-,$(addsuffix .la,$(ALL_BACKENDS)))
|
||||
|
@ -108,7 +109,8 @@ DISTFILES = abaton.c abaton.conf abaton.h agfafocus.c agfafocus.conf \
|
|||
snapscan-sources.h snapscan-usb.c snapscan-usb.h snapscan-options.c sp15c.c \
|
||||
sp15c.conf sp15c.h sp15c-scsi.h st400.c st400.conf st400.h stubs.c \
|
||||
tamarack.c tamarack.conf tamarack.h teco1.c teco1.h \
|
||||
teco1.conf umax1220u.c umax1220u-common.c \
|
||||
teco1.conf test.c test.conf test.h test-picture.c umax1220u.c \
|
||||
umax1220u-common.c \
|
||||
umax1220u.conf umax.c umax.conf umax.h umax_pp.c umax_pp.conf umax_pp.h \
|
||||
umax_pp_low.c umax_pp_low.h umax_pp_mid.c umax_pp_mid.h umax-scanner.c \
|
||||
umax-scanner.h umax-scsidef.h umax-uc1200s.c umax-uc1200se.c umax-uc1260.c \
|
||||
|
@ -333,6 +335,7 @@ libsane-st400.la: ../sanei/sanei_scsi.lo
|
|||
libsane-tamarack.la: ../sanei/sanei_config2.lo
|
||||
libsane-tamarack.la: ../sanei/sanei_constrain_value.lo
|
||||
libsane-tamarack.la: ../sanei/sanei_scsi.lo
|
||||
libsane-test.la: ../sanei/sanei_constrain_value.lo
|
||||
libsane-teco1.la: ../sanei/sanei_config2.lo
|
||||
libsane-teco1.la: ../sanei/sanei_constrain_value.lo
|
||||
libsane-teco1.la: ../sanei/sanei_scsi.lo
|
||||
|
|
|
@ -0,0 +1,834 @@
|
|||
/* sane - Scanner Access Now Easy.
|
||||
Copyright (C) 2002 Henning Meier-Geinitz <henning@meier-geinitz.de>
|
||||
This file is part of the SANE package.
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License as
|
||||
published by the Free Software Foundation; either version 2 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston,
|
||||
MA 02111-1307, USA.
|
||||
|
||||
As a special exception, the authors of SANE give permission for
|
||||
additional uses of the libraries contained in this release of SANE.
|
||||
|
||||
The exception is that, if you link a SANE library with other files
|
||||
to produce an executable, this does not by itself cause the
|
||||
resulting executable to be covered by the GNU General Public
|
||||
License. Your use of that executable is in no way restricted on
|
||||
account of linking the SANE library code into it.
|
||||
|
||||
This exception does not, however, invalidate any other reasons why
|
||||
the executable file might be covered by the GNU General Public
|
||||
License.
|
||||
|
||||
If you submit changes to SANE to the maintainers to be included in
|
||||
a subsequent release, you agree by submitting the changes that
|
||||
those changes may be distributed with this exception intact.
|
||||
|
||||
If you write modifications of your own for SANE, it is your choice
|
||||
whether to permit this exception to apply to your modifications.
|
||||
If you do not wish that, delete this exception notice.
|
||||
|
||||
This file implements test picture functions for the test backend.
|
||||
*/
|
||||
|
||||
#define BUFFER_SIZE (64 * 1024)
|
||||
|
||||
static SANE_Bool little_endian (void);
|
||||
|
||||
static SANE_Status
|
||||
init_picture_buffer (Test_Device * test_device, SANE_Byte ** buffer,
|
||||
size_t * buffer_size)
|
||||
{
|
||||
SANE_Word pattern_size = 0, pattern_distance = 0;
|
||||
SANE_Word line_count, b_size;
|
||||
SANE_Word lines = 0;
|
||||
SANE_Word bpl = test_device->bytes_per_line;
|
||||
SANE_Byte *b;
|
||||
SANE_Bool is_little_endian = little_endian ();
|
||||
|
||||
DBG (2, "(child) init_picture_buffer test_device=%p, buffer=%p, "
|
||||
"buffer_size=%p\n", test_device, buffer, buffer_size);
|
||||
|
||||
if (strcmp (test_device->val[opt_test_picture].s, "Solid black") == 0
|
||||
|| strcmp (test_device->val[opt_test_picture].s, "Solid white") == 0)
|
||||
{
|
||||
SANE_Byte pattern = 0;
|
||||
|
||||
b_size = BUFFER_SIZE;
|
||||
if (buffer_size)
|
||||
*buffer_size = b_size;
|
||||
|
||||
b = malloc (b_size);
|
||||
if (!b)
|
||||
{
|
||||
DBG (1, "(child) init_picture_buffer: couldn't malloc buffer\n");
|
||||
return SANE_STATUS_NO_MEM;
|
||||
}
|
||||
|
||||
if (buffer)
|
||||
*buffer = b;
|
||||
|
||||
if (strcmp (test_device->val[opt_test_picture].s, "Solid black") == 0)
|
||||
{
|
||||
DBG (3, "(child) init_picture_buffer: drawing solid black test "
|
||||
"picture %d bytes\n", b_size);
|
||||
if (test_device->params.format == SANE_FRAME_GRAY
|
||||
&& test_device->params.depth == 1)
|
||||
pattern = 0xff;
|
||||
else
|
||||
pattern = 0x00;
|
||||
}
|
||||
else
|
||||
{
|
||||
DBG (3, "(child) init_picture_buffer: drawing solid white test "
|
||||
"picture %d bytes\n", b_size);
|
||||
if (test_device->params.format == SANE_FRAME_GRAY
|
||||
&& test_device->params.depth == 1)
|
||||
pattern = 0x00;
|
||||
else
|
||||
pattern = 0xff;
|
||||
}
|
||||
memset (b, pattern, b_size);
|
||||
return SANE_STATUS_GOOD;
|
||||
}
|
||||
|
||||
/* Grid */
|
||||
if (strcmp (test_device->val[opt_test_picture].s, "Grid") == 0)
|
||||
{
|
||||
double p_size = (10.0 * SANE_UNFIX (test_device->val[opt_resolution].w)
|
||||
/ MM_PER_INCH);
|
||||
SANE_Word increment = 1;
|
||||
if (test_device->params.format == SANE_FRAME_RGB)
|
||||
increment *= 3;
|
||||
if (test_device->params.depth == 16)
|
||||
increment *= 2;
|
||||
|
||||
lines = 2 * p_size + 0.5;
|
||||
b_size = lines * bpl;
|
||||
if (buffer_size)
|
||||
*buffer_size = b_size;
|
||||
b = malloc (b_size);
|
||||
if (!b)
|
||||
{
|
||||
DBG (1, "(child) init_picture_buffer: couldn't malloc buffer\n");
|
||||
return SANE_STATUS_NO_MEM;
|
||||
}
|
||||
if (buffer)
|
||||
*buffer = b;
|
||||
DBG (3, "(child) init_picture_buffer: drawing grid test picture "
|
||||
"%d bytes, %d bpl, %d lines\n", b_size, bpl, lines);
|
||||
|
||||
for (line_count = 0; line_count < lines; line_count++)
|
||||
{
|
||||
SANE_Word x = 0;
|
||||
|
||||
for (x = 0; x < bpl; x += increment)
|
||||
{
|
||||
SANE_Word x1;
|
||||
SANE_Byte color = 0;
|
||||
|
||||
if (test_device->params.depth == 1)
|
||||
{
|
||||
if (test_device->params.format == SANE_FRAME_GRAY)
|
||||
{
|
||||
SANE_Byte value = 0;
|
||||
for (x1 = 0; x1 < 8; x1++)
|
||||
{
|
||||
if (((SANE_Word)
|
||||
((x * 8 / increment +
|
||||
(7 - x1)) / p_size) % 2) ^ (line_count >
|
||||
(SANE_Word)
|
||||
(p_size +
|
||||
0.5)) ^
|
||||
(test_device->params.format == SANE_FRAME_GRAY))
|
||||
color = 0x0;
|
||||
else
|
||||
color = 0x1;
|
||||
value |= (color << x1);
|
||||
}
|
||||
for (x1 = 0; x1 < increment; x1++)
|
||||
b[line_count * bpl + x + x1] = value;
|
||||
}
|
||||
else
|
||||
{
|
||||
SANE_Byte value = 0;
|
||||
for (x1 = 0; x1 < 8; x1++)
|
||||
{
|
||||
if (((SANE_Word) ((x * 8 / increment + x1) / p_size)
|
||||
% 2) ^ (line_count >
|
||||
(SANE_Word) (p_size +
|
||||
0.5)) ^ (test_device->
|
||||
params.format ==
|
||||
SANE_FRAME_GRAY))
|
||||
color = 0x0;
|
||||
else
|
||||
color = 0x1;
|
||||
value |= (color << x1);
|
||||
}
|
||||
for (x1 = 0; x1 < increment; x1++)
|
||||
b[line_count * bpl + x + x1] = value;
|
||||
}
|
||||
}
|
||||
else /* depth = 8, 16 */
|
||||
{
|
||||
if ((((SANE_Int) (x / increment / p_size)) % 2)
|
||||
^ (line_count > (SANE_Int) (p_size + 0.5)))
|
||||
color = 0x00;
|
||||
else
|
||||
color = 0xff;
|
||||
for (x1 = 0; x1 < increment; x1++)
|
||||
b[line_count * bpl + x + x1] = color;
|
||||
}
|
||||
}
|
||||
}
|
||||
return SANE_STATUS_GOOD;
|
||||
}
|
||||
|
||||
/* Color patterns */
|
||||
if (test_device->params.format == SANE_FRAME_GRAY
|
||||
&& test_device->params.depth == 1)
|
||||
{
|
||||
/* 1 bit black/white */
|
||||
pattern_size = 16;
|
||||
pattern_distance = 0;
|
||||
lines = 2 * (pattern_size + pattern_distance);
|
||||
b_size = lines * bpl;
|
||||
|
||||
if (buffer_size)
|
||||
*buffer_size = b_size;
|
||||
b = malloc (b_size);
|
||||
if (!b)
|
||||
{
|
||||
DBG (1, "(child) init_picture_buffer: couldn't malloc buffer\n");
|
||||
return SANE_STATUS_NO_MEM;
|
||||
}
|
||||
if (buffer)
|
||||
*buffer = b;
|
||||
DBG (3, "(child) init_picture_buffer: drawing b/w test picture "
|
||||
"%d bytes, %d bpl, %d lines\n", b_size, bpl, lines);
|
||||
memset (b, 255, b_size);
|
||||
for (line_count = 0; line_count < lines; line_count++)
|
||||
{
|
||||
SANE_Word x = 0;
|
||||
|
||||
if (line_count >= lines / 2)
|
||||
x += (pattern_size + pattern_distance) / 8;
|
||||
|
||||
while (x < bpl)
|
||||
{
|
||||
SANE_Word width;
|
||||
|
||||
width = pattern_size / 8;
|
||||
if (x + width >= bpl)
|
||||
width = bpl - x;
|
||||
memset (b + line_count * bpl + x, 0x00, width);
|
||||
x += (pattern_size + pattern_distance) * 2 / 8;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (test_device->params.format == SANE_FRAME_GRAY
|
||||
&& test_device->params.depth == 8)
|
||||
{
|
||||
/* 8 bit gray */
|
||||
pattern_size = 4;
|
||||
pattern_distance = 1;
|
||||
lines = 2 * (pattern_size + pattern_distance);
|
||||
b_size = lines * bpl;
|
||||
|
||||
if (buffer_size)
|
||||
*buffer_size = b_size;
|
||||
b = malloc (b_size);
|
||||
if (!b)
|
||||
{
|
||||
DBG (1, "(child) init_picture_buffer: couldn't malloc buffer\n");
|
||||
return SANE_STATUS_NO_MEM;
|
||||
}
|
||||
if (buffer)
|
||||
*buffer = b;
|
||||
DBG (3, "(child) init_picture_buffer: drawing 8 bit gray test picture "
|
||||
"%d bytes, %d bpl, %d lines\n", b_size, bpl, lines);
|
||||
memset (b, 0x55, b_size);
|
||||
for (line_count = 0; line_count < lines; line_count++)
|
||||
{
|
||||
SANE_Word x = pattern_distance;
|
||||
|
||||
if (line_count % (pattern_size + pattern_distance)
|
||||
< pattern_distance)
|
||||
continue;
|
||||
|
||||
while (x < bpl)
|
||||
{
|
||||
SANE_Word width;
|
||||
SANE_Byte color;
|
||||
|
||||
width = pattern_size;
|
||||
if (x + width >= bpl)
|
||||
width = bpl - x;
|
||||
if (line_count > (pattern_size + pattern_distance))
|
||||
color =
|
||||
0xff - ((x / (pattern_size + pattern_distance)) & 0xff);
|
||||
else
|
||||
color = (x / (pattern_size + pattern_distance)) & 0xff;
|
||||
memset (b + line_count * bpl + x, color, width);
|
||||
x += (pattern_size + pattern_distance);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
else if (test_device->params.format == SANE_FRAME_GRAY
|
||||
&& test_device->params.depth == 16)
|
||||
{
|
||||
/* 16 bit gray */
|
||||
pattern_size = 256;
|
||||
pattern_distance = 4;
|
||||
lines = 1 * (pattern_size + pattern_distance);
|
||||
b_size = lines * bpl;
|
||||
|
||||
if (buffer_size)
|
||||
*buffer_size = b_size;
|
||||
b = malloc (b_size);
|
||||
if (!b)
|
||||
{
|
||||
DBG (1, "(child) init_picture_buffer: couldn't malloc buffer\n");
|
||||
return SANE_STATUS_NO_MEM;
|
||||
}
|
||||
if (buffer)
|
||||
*buffer = b;
|
||||
DBG (3, "(child) init_picture_buffer: drawing 16 bit gray test picture "
|
||||
"%d bytes, %d bpl, %d lines\n", b_size, bpl, lines);
|
||||
memset (b, 0x55, b_size);
|
||||
for (line_count = 0; line_count < lines; line_count++)
|
||||
{
|
||||
SANE_Word x = pattern_distance * 2;
|
||||
|
||||
if (line_count % (pattern_size + pattern_distance)
|
||||
< pattern_distance)
|
||||
continue;
|
||||
|
||||
while (x < bpl)
|
||||
{
|
||||
SANE_Word width;
|
||||
SANE_Word x1;
|
||||
SANE_Byte pattern_lo, pattern_hi;
|
||||
|
||||
width = pattern_size * 2;
|
||||
if (x + width >= bpl)
|
||||
width = bpl - x;
|
||||
pattern_lo =
|
||||
((line_count - pattern_distance)
|
||||
% (pattern_size + pattern_distance)) & 0xff;
|
||||
for (x1 = 0; x1 < width; x1 += 2)
|
||||
{
|
||||
pattern_hi = (x1 / 2) & 0xff;
|
||||
if (is_little_endian)
|
||||
{
|
||||
b[line_count * bpl + x + x1 + 0] = pattern_lo;
|
||||
b[line_count * bpl + x + x1 + 1] = pattern_hi;
|
||||
}
|
||||
else
|
||||
{
|
||||
b[line_count * bpl + x + x1 + 0] = pattern_hi;
|
||||
b[line_count * bpl + x + x1 + 1] = pattern_lo;
|
||||
}
|
||||
}
|
||||
x += ((pattern_size + pattern_distance) * 2);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
else if (test_device->params.format == SANE_FRAME_RGB
|
||||
&& test_device->params.depth == 1)
|
||||
{
|
||||
/* 1 bit color */
|
||||
pattern_size = 16;
|
||||
pattern_distance = 0;
|
||||
lines = 2 * (pattern_size + pattern_distance);
|
||||
b_size = lines * bpl;
|
||||
|
||||
if (buffer_size)
|
||||
*buffer_size = b_size;
|
||||
b = malloc (b_size);
|
||||
if (!b)
|
||||
{
|
||||
DBG (1, "(child) init_picture_buffer: couldn't malloc buffer\n");
|
||||
return SANE_STATUS_NO_MEM;
|
||||
}
|
||||
if (buffer)
|
||||
*buffer = b;
|
||||
DBG (3, "(child) init_picture_buffer: drawing color lineart test "
|
||||
"picture %d bytes, %d bpl, %d lines\n", b_size, bpl, lines);
|
||||
memset (b, 0x55, b_size);
|
||||
|
||||
for (line_count = 0; line_count < lines; line_count++)
|
||||
{
|
||||
SANE_Word x = 0;
|
||||
SANE_Byte color = 0, color_r = 0, color_g = 0, color_b = 0;
|
||||
|
||||
if (line_count >= lines / 2)
|
||||
color = 7;
|
||||
while (x < bpl)
|
||||
{
|
||||
SANE_Word width;
|
||||
SANE_Word x2 = 0;
|
||||
|
||||
width = pattern_size / 8 * 3;
|
||||
if (x + width >= bpl)
|
||||
width = bpl - x;
|
||||
|
||||
color_b = (color & 1) * 0xff;
|
||||
color_g = ((color >> 1) & 1) * 0xff;
|
||||
color_r = ((color >> 2) & 1) * 0xff;
|
||||
|
||||
for (x2 = 0; x2 < width; x2 += 3)
|
||||
{
|
||||
b[line_count * bpl + x + x2 + 0] = color_r;
|
||||
b[line_count * bpl + x + x2 + 1] = color_g;
|
||||
b[line_count * bpl + x + x2 + 2] = color_b;
|
||||
}
|
||||
if (line_count < lines / 2)
|
||||
{
|
||||
++color;
|
||||
if (color >= 8)
|
||||
color = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (color == 0)
|
||||
color = 8;
|
||||
--color;
|
||||
}
|
||||
x += ((pattern_size + pattern_distance) / 8 * 3);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ((test_device->params.format == SANE_FRAME_RED
|
||||
|| test_device->params.format == SANE_FRAME_GREEN
|
||||
|| test_device->params.format == SANE_FRAME_BLUE)
|
||||
&& test_device->params.depth == 1)
|
||||
{
|
||||
/* 1 bit color three-pass */
|
||||
pattern_size = 16;
|
||||
pattern_distance = 0;
|
||||
lines = 2 * (pattern_size + pattern_distance);
|
||||
b_size = lines * bpl;
|
||||
|
||||
if (buffer_size)
|
||||
*buffer_size = b_size;
|
||||
b = malloc (b_size);
|
||||
if (!b)
|
||||
{
|
||||
DBG (1, "(child) init_picture_buffer: couldn't malloc buffer\n");
|
||||
return SANE_STATUS_NO_MEM;
|
||||
}
|
||||
if (buffer)
|
||||
*buffer = b;
|
||||
DBG (3, "(child) init_picture_buffer: drawing color lineart three-pass "
|
||||
"test picture %d bytes, %d bpl, %d lines\n", b_size, bpl, lines);
|
||||
memset (b, 0x55, b_size);
|
||||
|
||||
for (line_count = 0; line_count < lines; line_count++)
|
||||
{
|
||||
SANE_Word x = 0;
|
||||
SANE_Byte color = 0, color_r = 0, color_g = 0, color_b = 0;
|
||||
|
||||
if (line_count >= lines / 2)
|
||||
color = 7;
|
||||
while (x < bpl)
|
||||
{
|
||||
SANE_Word width;
|
||||
SANE_Word x2 = 0;
|
||||
|
||||
width = pattern_size / 8;
|
||||
if (x + width >= bpl)
|
||||
width = bpl - x;
|
||||
|
||||
color_b = (color & 1) * 0xff;
|
||||
color_g = ((color >> 1) & 1) * 0xff;
|
||||
color_r = ((color >> 2) & 1) * 0xff;
|
||||
|
||||
for (x2 = 0; x2 < width; x2++)
|
||||
{
|
||||
if (test_device->params.format == SANE_FRAME_RED)
|
||||
b[line_count * bpl + x + x2] = color_r;
|
||||
else if (test_device->params.format == SANE_FRAME_GREEN)
|
||||
b[line_count * bpl + x + x2] = color_g;
|
||||
else
|
||||
b[line_count * bpl + x + x2] = color_b;
|
||||
}
|
||||
if (line_count < lines / 2)
|
||||
{
|
||||
++color;
|
||||
if (color >= 8)
|
||||
color = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (color == 0)
|
||||
color = 8;
|
||||
--color;
|
||||
}
|
||||
x += (pattern_size + pattern_distance) / 8;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (test_device->params.format == SANE_FRAME_RGB
|
||||
&& test_device->params.depth == 8)
|
||||
{
|
||||
/* 8 bit color */
|
||||
pattern_size = 4;
|
||||
pattern_distance = 1;
|
||||
lines = 6 * (pattern_size + pattern_distance);
|
||||
b_size = lines * bpl;
|
||||
|
||||
if (buffer_size)
|
||||
*buffer_size = b_size;
|
||||
b = malloc (b_size);
|
||||
if (!b)
|
||||
{
|
||||
DBG (1, "(child) init_picture_buffer: couldn't malloc buffer\n");
|
||||
return SANE_STATUS_NO_MEM;
|
||||
}
|
||||
if (buffer)
|
||||
*buffer = b;
|
||||
DBG (3, "(child) init_picture_buffer: drawing 8 bit color test picture "
|
||||
"%d bytes, %d bpl, %d lines\n", b_size, bpl, lines);
|
||||
memset (b, 0x55, b_size);
|
||||
for (line_count = 0; line_count < lines; line_count++)
|
||||
{
|
||||
SANE_Word x = pattern_distance * 3;
|
||||
|
||||
if (line_count % (pattern_size + pattern_distance)
|
||||
< pattern_distance)
|
||||
continue;
|
||||
|
||||
while (x < bpl)
|
||||
{
|
||||
SANE_Word width;
|
||||
SANE_Byte color = 0, color_r = 0, color_g = 0, color_b = 0;
|
||||
SANE_Word x1;
|
||||
|
||||
width = pattern_size * 3;
|
||||
if (x + width >= bpl)
|
||||
width = bpl - x;
|
||||
|
||||
if ((line_count / (pattern_size + pattern_distance)) & 1)
|
||||
color =
|
||||
0xff - ((x / ((pattern_size + pattern_distance) * 3))
|
||||
& 0xff);
|
||||
else
|
||||
color = (x / ((pattern_size + pattern_distance) * 3)) & 0xff;
|
||||
|
||||
if (line_count / (pattern_size + pattern_distance) < 2)
|
||||
{
|
||||
color_r = color;
|
||||
color_g = 0;
|
||||
color_b = 0;
|
||||
}
|
||||
else if (line_count / (pattern_size + pattern_distance) < 4)
|
||||
{
|
||||
color_r = 0;
|
||||
color_g = color;
|
||||
color_b = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
color_r = 0;
|
||||
color_g = 0;
|
||||
color_b = color;
|
||||
}
|
||||
|
||||
for (x1 = 0; x1 < width; x1 += 3)
|
||||
{
|
||||
b[line_count * bpl + x + x1 + 0] = color_r;
|
||||
b[line_count * bpl + x + x1 + 1] = color_g;
|
||||
b[line_count * bpl + x + x1 + 2] = color_b;
|
||||
}
|
||||
|
||||
x += ((pattern_size + pattern_distance) * 3);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
else if ((test_device->params.format == SANE_FRAME_RED
|
||||
|| test_device->params.format == SANE_FRAME_GREEN
|
||||
|| test_device->params.format == SANE_FRAME_BLUE)
|
||||
&& test_device->params.depth == 8)
|
||||
{
|
||||
/* 8 bit color three-pass */
|
||||
pattern_size = 4;
|
||||
pattern_distance = 1;
|
||||
lines = 6 * (pattern_size + pattern_distance);
|
||||
b_size = lines * bpl;
|
||||
|
||||
if (buffer_size)
|
||||
*buffer_size = b_size;
|
||||
b = malloc (b_size);
|
||||
if (!b)
|
||||
{
|
||||
DBG (1, "(child) init_picture_buffer: couldn't malloc buffer\n");
|
||||
return SANE_STATUS_NO_MEM;
|
||||
}
|
||||
if (buffer)
|
||||
*buffer = b;
|
||||
DBG (3, "(child) init_picture_buffer: drawing 8 bit color three-pass "
|
||||
"test picture %d bytes, %d bpl, %d lines\n", b_size, bpl, lines);
|
||||
memset (b, 0x55, b_size);
|
||||
for (line_count = 0; line_count < lines; line_count++)
|
||||
{
|
||||
SANE_Word x = pattern_distance;
|
||||
|
||||
if (line_count % (pattern_size + pattern_distance)
|
||||
< pattern_distance)
|
||||
continue;
|
||||
|
||||
while (x < bpl)
|
||||
{
|
||||
SANE_Word width;
|
||||
SANE_Byte color = 0;
|
||||
|
||||
width = pattern_size;
|
||||
if (x + width >= bpl)
|
||||
width = bpl - x;
|
||||
|
||||
if ((line_count / (pattern_size + pattern_distance)) & 1)
|
||||
color =
|
||||
0xff - (x / ((pattern_size + pattern_distance)) & 0xff);
|
||||
else
|
||||
color = (x / (pattern_size + pattern_distance)) & 0xff;
|
||||
|
||||
if (line_count / (pattern_size + pattern_distance) < 2)
|
||||
{
|
||||
if (test_device->params.format != SANE_FRAME_RED)
|
||||
color = 0x00;
|
||||
}
|
||||
else if (line_count / (pattern_size + pattern_distance) < 4)
|
||||
{
|
||||
if (test_device->params.format != SANE_FRAME_GREEN)
|
||||
color = 0x00;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (test_device->params.format != SANE_FRAME_BLUE)
|
||||
color = 0x00;
|
||||
}
|
||||
memset (b + line_count * bpl + x, color, width);
|
||||
|
||||
x += (pattern_size + pattern_distance);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (test_device->params.format == SANE_FRAME_RGB
|
||||
&& test_device->params.depth == 16)
|
||||
{
|
||||
/* 16 bit color */
|
||||
pattern_size = 256;
|
||||
pattern_distance = 4;
|
||||
lines = pattern_size + pattern_distance;
|
||||
b_size = lines * bpl;
|
||||
|
||||
if (buffer_size)
|
||||
*buffer_size = b_size;
|
||||
b = malloc (b_size);
|
||||
if (!b)
|
||||
{
|
||||
DBG (1, "(child) init_picture_buffer: couldn't malloc buffer\n");
|
||||
return SANE_STATUS_NO_MEM;
|
||||
}
|
||||
if (buffer)
|
||||
*buffer = b;
|
||||
DBG (3,
|
||||
"(child) init_picture_buffer: drawing 16 bit color test picture "
|
||||
"%d bytes, %d bpl, %d lines\n", b_size, bpl, lines);
|
||||
memset (b, 0x55, b_size);
|
||||
for (line_count = 0; line_count < lines; line_count++)
|
||||
{
|
||||
SANE_Word x = pattern_distance * 2 * 3;
|
||||
|
||||
if (line_count % (pattern_size + pattern_distance)
|
||||
< pattern_distance)
|
||||
continue;
|
||||
|
||||
while (x < bpl)
|
||||
{
|
||||
SANE_Word width;
|
||||
SANE_Word x1;
|
||||
SANE_Byte color_hi = 0, color_lo = 0;
|
||||
SANE_Byte color_hi_r = 0, color_lo_r = 0;
|
||||
SANE_Byte color_hi_g = 0, color_lo_g = 0;
|
||||
SANE_Byte color_hi_b = 0, color_lo_b = 0;
|
||||
|
||||
width = pattern_size * 2 * 3;
|
||||
if (x + width >= bpl)
|
||||
width = bpl - x;
|
||||
|
||||
|
||||
for (x1 = 0; x1 < width; x1 += 6)
|
||||
{
|
||||
color_lo =
|
||||
((line_count + pattern_size)
|
||||
% (pattern_size + pattern_distance)) & 0xff;
|
||||
color_hi = (x1 / 6) & 0xff;
|
||||
if (((x / ((pattern_size + pattern_distance) * 6)) % 3) ==
|
||||
0)
|
||||
{
|
||||
color_lo_r = color_lo;
|
||||
color_hi_r = color_hi;
|
||||
color_lo_g = 0;
|
||||
color_hi_g = 0;
|
||||
color_lo_b = 0;
|
||||
color_hi_b = 0;
|
||||
}
|
||||
else if (((x / ((pattern_size + pattern_distance) * 6)) % 3)
|
||||
== 1)
|
||||
{
|
||||
color_lo_r = 0;
|
||||
color_hi_r = 0;
|
||||
color_lo_g = color_lo;
|
||||
color_hi_g = color_hi;
|
||||
color_lo_b = 0;
|
||||
color_hi_b = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
color_lo_r = 0;
|
||||
color_hi_r = 0;
|
||||
color_lo_g = 0;
|
||||
color_hi_g = 0;
|
||||
color_lo_b = color_lo;
|
||||
color_hi_b = color_hi;
|
||||
}
|
||||
if (is_little_endian)
|
||||
{
|
||||
b[line_count * bpl + x + x1 + 0] = color_lo_r;
|
||||
b[line_count * bpl + x + x1 + 1] = color_hi_r;
|
||||
b[line_count * bpl + x + x1 + 2] = color_lo_g;
|
||||
b[line_count * bpl + x + x1 + 3] = color_hi_g;
|
||||
b[line_count * bpl + x + x1 + 4] = color_lo_b;
|
||||
b[line_count * bpl + x + x1 + 5] = color_hi_b;
|
||||
}
|
||||
else
|
||||
{
|
||||
b[line_count * bpl + x + x1 + 0] = color_hi_r;
|
||||
b[line_count * bpl + x + x1 + 1] = color_lo_r;
|
||||
b[line_count * bpl + x + x1 + 2] = color_hi_g;
|
||||
b[line_count * bpl + x + x1 + 3] = color_lo_g;
|
||||
b[line_count * bpl + x + x1 + 4] = color_hi_b;
|
||||
b[line_count * bpl + x + x1 + 5] = color_lo_b;
|
||||
}
|
||||
}
|
||||
x += ((pattern_size + pattern_distance) * 2 * 3);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
else if ((test_device->params.format == SANE_FRAME_RED
|
||||
|| test_device->params.format == SANE_FRAME_GREEN
|
||||
|| test_device->params.format == SANE_FRAME_BLUE)
|
||||
&& test_device->params.depth == 16)
|
||||
{
|
||||
/* 16 bit color three-pass */
|
||||
pattern_size = 256;
|
||||
pattern_distance = 4;
|
||||
lines = pattern_size + pattern_distance;
|
||||
b_size = lines * bpl;
|
||||
|
||||
if (buffer_size)
|
||||
*buffer_size = b_size;
|
||||
b = malloc (b_size);
|
||||
if (!b)
|
||||
{
|
||||
DBG (1, "(child) init_picture_buffer: couldn't malloc buffer\n");
|
||||
return SANE_STATUS_NO_MEM;
|
||||
}
|
||||
if (buffer)
|
||||
*buffer = b;
|
||||
DBG (3, "(child) init_picture_buffer: drawing 16 bit color three-pass "
|
||||
"test picture %d bytes, %d bpl, %d lines\n", b_size, bpl, lines);
|
||||
memset (b, 0x55, b_size);
|
||||
for (line_count = 0; line_count < lines; line_count++)
|
||||
{
|
||||
SANE_Word x = pattern_distance * 2;
|
||||
|
||||
if (line_count % (pattern_size + pattern_distance)
|
||||
< pattern_distance)
|
||||
continue;
|
||||
|
||||
while (x < bpl)
|
||||
{
|
||||
SANE_Word width;
|
||||
SANE_Word x1;
|
||||
SANE_Byte color_hi = 0, color_lo = 0;
|
||||
|
||||
width = pattern_size * 2;
|
||||
if (x + width >= bpl)
|
||||
width = bpl - x;
|
||||
|
||||
|
||||
for (x1 = 0; x1 < width; x1 += 2)
|
||||
{
|
||||
color_lo =
|
||||
((line_count + pattern_size)
|
||||
% (pattern_size + pattern_distance)) & 0xff;
|
||||
color_hi = (x1 / 2) & 0xff;
|
||||
if (((x / ((pattern_size + pattern_distance) * 2)) % 3) ==
|
||||
0)
|
||||
{
|
||||
if (test_device->params.format != SANE_FRAME_RED)
|
||||
{
|
||||
color_lo = 0x00;
|
||||
color_hi = 0x00;
|
||||
}
|
||||
}
|
||||
else if (((x / ((pattern_size + pattern_distance) * 2)) % 3)
|
||||
== 1)
|
||||
{
|
||||
if (test_device->params.format != SANE_FRAME_GREEN)
|
||||
{
|
||||
color_lo = 0x00;
|
||||
color_hi = 0x00;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (test_device->params.format != SANE_FRAME_BLUE)
|
||||
{
|
||||
color_lo = 0x00;
|
||||
color_hi = 0x00;
|
||||
}
|
||||
}
|
||||
|
||||
if (is_little_endian)
|
||||
{
|
||||
b[line_count * bpl + x + x1 + 0] = color_lo;
|
||||
b[line_count * bpl + x + x1 + 1] = color_hi;
|
||||
}
|
||||
else
|
||||
{
|
||||
b[line_count * bpl + x + x1 + 0] = color_hi;
|
||||
b[line_count * bpl + x + x1 + 1] = color_lo;
|
||||
}
|
||||
|
||||
}
|
||||
x += ((pattern_size + pattern_distance) * 2);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
else /* Huh? */
|
||||
{
|
||||
DBG (1, "(child) init_picture_buffer: unknown mode\n");
|
||||
return SANE_STATUS_INVAL;
|
||||
}
|
||||
|
||||
return SANE_STATUS_GOOD;
|
||||
}
|
Plik diff jest za duży
Load Diff
|
@ -0,0 +1,81 @@
|
|||
# test backend configuration file
|
||||
########################################
|
||||
|
||||
# number of test devices
|
||||
number_of_devices 2
|
||||
|
||||
# Initial option values and ranges
|
||||
########################################
|
||||
|
||||
# Scan mode (Color, Gray)
|
||||
mode Gray
|
||||
|
||||
# Bit depth (1, 8, 16)
|
||||
depth 8
|
||||
|
||||
# Hand-scanner mode (true, false)
|
||||
hand-scanner false
|
||||
|
||||
# Three-pass mode (true, false)
|
||||
three-pass false
|
||||
|
||||
# Three-pass order (RGB, RBG, GBR, GRB, BGR, BRG)
|
||||
three-pass-order RGB
|
||||
|
||||
# Resolution (dpi)
|
||||
resolution_min 1.0
|
||||
resolution_max 1200.0
|
||||
resolution_quant 1.0
|
||||
resolution 50.0
|
||||
|
||||
# Draw test picture ("Solid black", "Solid white", "Color pattern", "Grid")
|
||||
test-picture "Solid black"
|
||||
|
||||
# Read-limit (true, false)
|
||||
read-limit false
|
||||
|
||||
# Read-limit size (1 - 65536 bytes)
|
||||
read-limit-size 1
|
||||
|
||||
# Read-delay (true, false)
|
||||
read-delay false
|
||||
|
||||
# Read-delay duration (1000 - 200,000 microseconds)
|
||||
read-delay-duration 1000
|
||||
|
||||
# Status code (return-value) of sane_read() ("Default",
|
||||
# "SANE_STATUS_UNSUPPORTED",
|
||||
# "SANE_STATUS_CANCELLED", "SANE_STATUS_DEVICE_BUSY", "SANE_STATUS_INVAL",
|
||||
# "SANE_STATUS_EOF", "SANE_STATUS_JAMMED", "SANE_STATUS_NO_DOCS",
|
||||
# "SANE_STATUS_COVER_OPEN", "SANE_STATUS_IO_ERROR", "SANE_STATUS_NO_MEM",
|
||||
# "SANE_STATUS_ACCESS_DENIED"
|
||||
read-status-code "Default"
|
||||
|
||||
# Fuzzy parameters (true, false)
|
||||
fuzzy-parameters false
|
||||
|
||||
# Non-blocking io (true, false)
|
||||
non-blocking false
|
||||
|
||||
# Support select fd (true, false)
|
||||
select-fd false
|
||||
|
||||
# Enable test options (true, false)
|
||||
enable-test-options false
|
||||
|
||||
# Geometry (mm)
|
||||
geometry_min 0.0
|
||||
geometry_max 200.0
|
||||
geometry_quant 1.0
|
||||
|
||||
# Top-left x position (mm)
|
||||
tl_x 0.0
|
||||
|
||||
# Top-left y position (mm)
|
||||
tl_y 0.0
|
||||
|
||||
# Bottom-right x position (mm)
|
||||
br_x 80.0
|
||||
|
||||
# Bottom-right y position (mm)
|
||||
br_y 100.0
|
|
@ -0,0 +1,103 @@
|
|||
#ifndef test_h
|
||||
#define test_h
|
||||
|
||||
#define MM_PER_INCH 25.4
|
||||
|
||||
typedef enum
|
||||
{
|
||||
param_none = 0,
|
||||
param_bool,
|
||||
param_int,
|
||||
param_fixed,
|
||||
param_string
|
||||
}
|
||||
parameter_type;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
opt_num_opts = 0,
|
||||
opt_mode_group,
|
||||
opt_mode,
|
||||
opt_depth,
|
||||
opt_hand_scanner,
|
||||
opt_three_pass, /* 5 */
|
||||
opt_three_pass_order,
|
||||
opt_resolution,
|
||||
opt_special_group,
|
||||
opt_test_picture,
|
||||
opt_read_limit, /* 10 */
|
||||
opt_read_limit_size,
|
||||
opt_read_delay,
|
||||
opt_read_delay_duration,
|
||||
opt_read_status_code,
|
||||
opt_fuzzy_parameters,
|
||||
opt_non_blocking,
|
||||
opt_select_fd,
|
||||
opt_enable_test_options,
|
||||
opt_print_options,
|
||||
opt_geometry_group,
|
||||
opt_tl_x,
|
||||
opt_tl_y,
|
||||
opt_br_x,
|
||||
opt_br_y,
|
||||
opt_bool_group,
|
||||
opt_bool_soft_select_soft_detect,
|
||||
opt_bool_hard_select_soft_detect,
|
||||
opt_bool_hard_select,
|
||||
opt_bool_soft_detect,
|
||||
opt_bool_soft_select_soft_detect_emulated,
|
||||
opt_bool_soft_select_soft_detect_auto,
|
||||
opt_int_group,
|
||||
opt_int,
|
||||
opt_int_constraint_range,
|
||||
opt_int_constraint_word_list,
|
||||
opt_int_array,
|
||||
opt_int_array_constraint_range,
|
||||
opt_int_array_constraint_word_list,
|
||||
opt_fixed_group,
|
||||
opt_fixed,
|
||||
opt_fixed_constraint_range,
|
||||
opt_fixed_constraint_word_list,
|
||||
opt_string_group,
|
||||
opt_string,
|
||||
opt_string_constraint_string_list,
|
||||
opt_string_constraint_long_string_list,
|
||||
opt_button_group,
|
||||
opt_button,
|
||||
/* must come last: */
|
||||
num_options
|
||||
}
|
||||
test_opts;
|
||||
|
||||
typedef union
|
||||
{
|
||||
SANE_Word w;
|
||||
SANE_Word *wa; /* word array */
|
||||
SANE_String s;
|
||||
}
|
||||
Option_Value;
|
||||
|
||||
|
||||
typedef struct Test_Device
|
||||
{
|
||||
struct Test_Device *next;
|
||||
SANE_Device sane;
|
||||
SANE_Option_Descriptor opt[num_options];
|
||||
Option_Value val[num_options];
|
||||
SANE_Parameters params;
|
||||
SANE_String name;
|
||||
SANE_Int reader_pid;
|
||||
SANE_Int pipe;
|
||||
FILE *pipe_handle;
|
||||
SANE_Word pass;
|
||||
SANE_Word bytes_per_line;
|
||||
SANE_Word lines;
|
||||
SANE_Int bytes_total;
|
||||
SANE_Bool open;
|
||||
SANE_Bool scanning;
|
||||
SANE_Bool cancelled;
|
||||
SANE_Bool eof;
|
||||
}
|
||||
Test_Device;
|
||||
|
||||
#endif /* test_h */
|
Ładowanie…
Reference in New Issue