* backend/genesys.c backend/genesys.h backend/genesys_low.h: added

options for enabling/disabling horizontal interpolation at high
   resolutions and selection of color filter in grayscale and
   lineart modes.
 * backend/genesys_gl841.c: implemented color filter selection.
merge-requests/1/head
Pierre Willenbrock 2006-06-07 22:39:09 +00:00
rodzic c25e16f38a
commit b53cfc23fe
5 zmienionych plików z 123 dodań i 32 usunięć

Wyświetl plik

@ -1,3 +1,12 @@
2006-06-07 Pierre Willenbrock <pierre@pirsoft.dnsalias.org>
* backend/genesys.c backend/genesys.h backend/genesys_low.h: added
options for enabling/disabling horizontal interpolation at high
resolutions and selection of color filter in grayscale and
lineart modes.
* backend/genesys_gl841.c: implemented color filter selection.
2006-06-07 Gerhard Jaeger <gerhard@gjaeger.de>
* configure, configure.in, backend/Makefile.in

Wyświetl plik

@ -91,6 +91,13 @@ static SANE_String_Const mode_list[] = {
0
};
static SANE_String_Const color_filter_list[] = {
SANE_I18N ("Red"),
SANE_I18N ("Green"),
SANE_I18N ("Blue"),
0
};
static SANE_String_Const source_list[] = {
SANE_I18N ("Flatbed"),
SANE_I18N ("Transparency Adapter"),
@ -4361,13 +4368,14 @@ max_string_size (const SANE_String_Const strings[])
static SANE_Status
calc_parameters (Genesys_Scanner * s)
{
SANE_String mode, source;
SANE_String mode, source, color_filter;
SANE_Status status = SANE_STATUS_GOOD;
SANE_Int depth = 0, resolution = 0;
double tl_x = 0, tl_y = 0, br_x = 0, br_y = 0;
mode = s->val[OPT_MODE].s;
source = s->val[OPT_SOURCE].s;
color_filter = s->val[OPT_COLOR_FILTER].s;
depth = s->val[OPT_BIT_DEPTH].w;
resolution = s->val[OPT_RESOLUTION].w;
tl_x = SANE_UNFIX (s->val[OPT_TL_X].w);
@ -4389,8 +4397,12 @@ calc_parameters (Genesys_Scanner * s)
s->dev->settings.depth = depth;
/* interpolation */
s->dev->settings.disable_interpolation = s->val[OPT_DISABLE_INTERPOLATION].w == SANE_TRUE;
/* Hardware settings */
if (resolution > s->dev->sensor.optical_res)
if (resolution > s->dev->sensor.optical_res &&
s->dev->settings.disable_interpolation)
s->dev->settings.xres = s->dev->sensor.optical_res;
else
s->dev->settings.xres = resolution;
@ -4441,6 +4453,14 @@ calc_parameters (Genesys_Scanner * s)
/* threshold setting */
s->dev->settings.threshold = 2.55 * (SANE_UNFIX (s->val[OPT_THRESHOLD].w));
/* color filter */
if (strcmp(color_filter, "Red") == 0)
s->dev->settings.color_filter = 0;
else if (strcmp(color_filter, "Blue") == 0)
s->dev->settings.color_filter = 2;
else
s->dev->settings.color_filter = 1;
return status;
}
@ -4630,6 +4650,30 @@ init_options (Genesys_Scanner * s)
s->opt[OPT_THRESHOLD].constraint.range = &threshold_percentage_range;
s->val[OPT_THRESHOLD].w = SANE_FIX(50);
/* disable_interpolation */
s->opt[OPT_DISABLE_INTERPOLATION].name = "disable-interpolation";
s->opt[OPT_DISABLE_INTERPOLATION].title = SANE_I18N("Disable interpolation");
s->opt[OPT_DISABLE_INTERPOLATION].desc =
SANE_I18N
("When using high resolutions where the horizontal resolution is smaller "
"than the vertical resolution this disables horizontal interpolation.");
s->opt[OPT_DISABLE_INTERPOLATION].type = SANE_TYPE_BOOL;
s->opt[OPT_DISABLE_INTERPOLATION].unit = SANE_UNIT_NONE;
s->opt[OPT_DISABLE_INTERPOLATION].constraint_type = SANE_CONSTRAINT_NONE;
s->val[OPT_DISABLE_INTERPOLATION].w = SANE_FALSE;
/* color filter */
s->opt[OPT_COLOR_FILTER].name = "color-filter";
s->opt[OPT_COLOR_FILTER].title = SANE_I18N("Color Filter");
s->opt[OPT_COLOR_FILTER].desc =
SANE_I18N
("When using gray or lineart this option selects the used color.");
s->opt[OPT_COLOR_FILTER].type = SANE_TYPE_STRING;
s->opt[OPT_COLOR_FILTER].constraint_type = SANE_CONSTRAINT_STRING_LIST;
s->opt[OPT_COLOR_FILTER].size = max_string_size (color_filter_list);
s->opt[OPT_COLOR_FILTER].constraint.string_list = color_filter_list;
s->val[OPT_COLOR_FILTER].s = strdup("Green");
/* Powersave time (turn lamp off) */
s->opt[OPT_LAMP_OFF_TIME].name = "lamp-off-time";
s->opt[OPT_LAMP_OFF_TIME].title = SANE_I18N ("Lamp off time");
@ -5162,13 +5206,13 @@ sane_control_option (SANE_Handle handle, SANE_Int option,
case OPT_BR_X:
case OPT_BR_Y:
case OPT_THRESHOLD:
case OPT_DISABLE_INTERPOLATION:
case OPT_LAMP_OFF_TIME:
*(SANE_Word *) val = s->val[option].w;
break;
/* string options: */
case OPT_MODE:
strcpy (val, s->val[option].s);
break;
case OPT_COLOR_FILTER:
case OPT_SOURCE:
strcpy (val, s->val[option].s);
break;
@ -5209,6 +5253,7 @@ sane_control_option (SANE_Handle handle, SANE_Int option,
case OPT_RESOLUTION:
case OPT_BIT_DEPTH:
case OPT_THRESHOLD:
case OPT_DISABLE_INTERPOLATION:
case OPT_PREVIEW:
s->val[option].w = *(SANE_Word *) val;
RIE (calc_parameters (s));
@ -5245,14 +5290,18 @@ sane_control_option (SANE_Handle handle, SANE_Int option,
{
ENABLE (OPT_THRESHOLD);
DISABLE (OPT_BIT_DEPTH);
ENABLE (OPT_COLOR_FILTER);
}
else
{
DISABLE (OPT_THRESHOLD);
if (strcmp (s->val[option].s, "Gray") == 0)
if (strcmp (s->val[option].s, "Gray") == 0) {
ENABLE (OPT_COLOR_FILTER);
create_bpp_list (s, s->dev->model->bpp_gray_values);
else
} else {
DISABLE (OPT_COLOR_FILTER);
create_bpp_list (s, s->dev->model->bpp_color_values);
}
if (s->bpp_list[0] < 2)
DISABLE (OPT_BIT_DEPTH);
else
@ -5261,6 +5310,12 @@ sane_control_option (SANE_Handle handle, SANE_Int option,
RIE (calc_parameters (s));
myinfo |= SANE_INFO_RELOAD_PARAMS | SANE_INFO_RELOAD_OPTIONS;
break;
case OPT_COLOR_FILTER:
if (s->val[option].s)
free (s->val[option].s);
s->val[option].s = strdup (val);
RIE (calc_parameters (s));
break;
case OPT_LAMP_OFF_TIME:
if (*(SANE_Word *) val != s->val[option].w)
{

Wyświetl plik

@ -84,6 +84,8 @@ enum Genesys_Option
OPT_EXTRAS_GROUP,
OPT_LAMP_OFF_TIME,
OPT_THRESHOLD,
OPT_DISABLE_INTERPOLATION,
OPT_COLOR_FILTER,
/* must come last: */
NUM_OPTIONS
};

Wyświetl plik

@ -1524,9 +1524,9 @@ gl841_send_slope_table (Genesys_Device * dev, int table_nr,
int start_address;
SANE_Status status;
u_int8_t *table;
#ifdef WORDS_BIGENDIAN
/*#ifdef WORDS_BIGENDIAN*/
int i;
#endif
/*#endif*/
DBG (DBG_proc, "gl841_send_slope_table (table_nr = %d, steps = %d)\n",
table_nr, steps);
@ -1542,23 +1542,23 @@ gl841_send_slope_table (Genesys_Device * dev, int table_nr,
else /* reserved */
return SANE_STATUS_INVAL;
#ifdef WORDS_BIGENDIAN
/*#ifdef WORDS_BIGENDIAN*/
table = (u_int8_t*)malloc(steps * 2);
for(i = 0; i < steps; i++) {
table[i * 2] = slope_table[i] & 0xff;
table[i * 2 + 1] = slope_table[i] >> 8;
}
#else
/*#else
table = (u_int8_t*)slope_table;
#endif
#endif*/
status =
sanei_genesys_set_buffer_address (dev, start_address + table_nr * 0x200);
if (status != SANE_STATUS_GOOD)
{
#ifdef WORDS_BIGENDIAN
/*#ifdef WORDS_BIGENDIAN*/
free(table);
#endif
/*#endif*/
DBG (DBG_error,
"gl841_send_slope_table: failed to set buffer address: %s\n",
sane_strstatus (status));
@ -1570,18 +1570,18 @@ gl841_send_slope_table (Genesys_Device * dev, int table_nr,
steps * 2);
if (status != SANE_STATUS_GOOD)
{
#ifdef WORDS_BIGENDIAN
/*#ifdef WORDS_BIGENDIAN*/
free(table);
#endif
/*#endif*/
DBG (DBG_error,
"gl841_send_slope_table: failed to send slope table: %s\n",
sane_strstatus (status));
return status;
}
#ifdef WORDS_BIGENDIAN
/*#ifdef WORDS_BIGENDIAN*/
free(table);
#endif
/*#endif*/
DBG (DBG_proc, "gl841_send_slope_table: completed\n");
return status;
}
@ -2384,6 +2384,7 @@ gl841_init_optical_regs_scan(Genesys_Device * dev,
int channels,
int depth,
SANE_Bool half_ccd,
int color_filter,
int flags
)
{
@ -2485,9 +2486,19 @@ gl841_init_optical_regs_scan(Genesys_Device * dev,
r->value &= ~(REG04_FILTER | REG04_AFEMOD);
/* we could make the color filter used an advanced option of the
backend */
if (channels == 1)
r->value |= 0x18; /* green filter */
else
if (channels == 1) {
switch (color_filter) {
case 0:
r->value |= 0x14; /* red filter */
break;
case 2:
r->value |= 0x1c; /* blue filter */
break;
default:
r->value |= 0x18; /* green filter */
break;
}
} else
r->value |= 0x10; /* color pixel by pixel */
/* enable gamma tables */
@ -2589,6 +2600,7 @@ gl841_init_scan_regs (Genesys_Device * dev,
float lines,
unsigned int depth,
unsigned int channels,
int color_filter,
unsigned int flags
)
{
@ -2798,18 +2810,19 @@ dummy \ scanned lines
flags |= SCAN_FLAG_DISABLE_GAMMA;
status = gl841_init_optical_regs_scan(dev,
reg,
exposure_time,
used_res,
start,
used_pixels,
channels,
depth,
half_ccd,
((flags & SCAN_FLAG_DISABLE_SHADING)?
OPTICAL_FLAG_DISABLE_SHADING:0) |
((flags & SCAN_FLAG_DISABLE_GAMMA)?
OPTICAL_FLAG_DISABLE_GAMMA:0));
reg,
exposure_time,
used_res,
start,
used_pixels,
channels,
depth,
half_ccd,
color_filter,
((flags & SCAN_FLAG_DISABLE_SHADING)?
OPTICAL_FLAG_DISABLE_SHADING:0) |
((flags & SCAN_FLAG_DISABLE_GAMMA)?
OPTICAL_FLAG_DISABLE_GAMMA:0));
if (status != SANE_STATUS_GOOD)
return status;
@ -3706,6 +3719,7 @@ gl841_search_start_position (Genesys_Device * dev)
dev->model->search_lines,
8,
1,
1,/*green*/
SCAN_FLAG_DISABLE_SHADING |
SCAN_FLAG_DISABLE_GAMMA |
SCAN_FLAG_IGNORE_LINE_DISTANCE |
@ -3826,6 +3840,7 @@ gl841_init_regs_for_coarse_calibration (Genesys_Device * dev)
20,
16,
channels,
dev->settings.color_filter,
SCAN_FLAG_DISABLE_SHADING |
SCAN_FLAG_DISABLE_GAMMA |
SCAN_FLAG_SINGLE_LINE |
@ -3891,6 +3906,7 @@ gl841_init_regs_for_shading (Genesys_Device * dev)
dev->model->shading_lines,
16,
channels,
dev->settings.color_filter,
SCAN_FLAG_DISABLE_SHADING |
SCAN_FLAG_DISABLE_GAMMA |
/* we don't handle differing shading areas very well */
@ -4009,6 +4025,7 @@ gl841_init_regs_for_scan (Genesys_Device * dev)
dev->settings.lines,
depth,
channels,
dev->settings.color_filter,
0
);
@ -4165,6 +4182,7 @@ gl841_led_calibration (Genesys_Device * dev)
1,
16,
channels,
dev->settings.color_filter,
SCAN_FLAG_DISABLE_SHADING |
SCAN_FLAG_DISABLE_GAMMA |
SCAN_FLAG_SINGLE_LINE |
@ -4355,6 +4373,7 @@ gl841_offset_calibration (Genesys_Device * dev)
1,
16,
channels,
dev->settings.color_filter,
SCAN_FLAG_DISABLE_SHADING |
SCAN_FLAG_DISABLE_GAMMA |
SCAN_FLAG_SINGLE_LINE |
@ -4742,6 +4761,7 @@ gl841_coarse_gain_calibration (Genesys_Device * dev, int dpi)
1,
16,
channels,
dev->settings.color_filter,
SCAN_FLAG_DISABLE_SHADING |
SCAN_FLAG_DISABLE_GAMMA |
SCAN_FLAG_SINGLE_LINE |
@ -4875,6 +4895,7 @@ gl841_init_regs_for_warmup (Genesys_Device * dev,
1,
16,
*channels,
dev->settings.color_filter,
SCAN_FLAG_DISABLE_SHADING |
SCAN_FLAG_DISABLE_GAMMA |
SCAN_FLAG_SINGLE_LINE |
@ -5077,6 +5098,7 @@ gl841_init (Genesys_Device * dev)
1,
16,
3,
0,
SCAN_FLAG_DISABLE_SHADING |
SCAN_FLAG_DISABLE_GAMMA |
SCAN_FLAG_SINGLE_LINE |

Wyświetl plik

@ -404,6 +404,9 @@ typedef struct
/* BW threshold */
int threshold;
/* Disable interpolation for xres<yres*/
int disable_interpolation;
} Genesys_Settings;
typedef struct Genesys_Current_Setup