add calibration file name option

- add an option to set calibration cache file name
- update man page and fr translation
merge-requests/1/head
Stphane Voltz 2013-08-07 06:42:14 +02:00
rodzic ff58b225bf
commit 63d12e3ee9
4 zmienionych plików z 95 dodań i 3 usunięć

Wyświetl plik

@ -5792,7 +5792,7 @@ init_options (Genesys_Scanner * s)
/* 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].title = SANE_I18N ("Color filter");
s->opt[OPT_COLOR_FILTER].desc =
SANE_I18N
("When using gray or lineart this option selects the used color.");
@ -5819,6 +5819,24 @@ init_options (Genesys_Scanner * s)
DISABLE (OPT_COLOR_FILTER);
}
/* calibration stor file name */
s->opt[OPT_CALIBRATION_FILE].name = "calibration-file";
s->opt[OPT_CALIBRATION_FILE].title = SANE_I18N ("Calibration file");
s->opt[OPT_CALIBRATION_FILE].desc = SANE_I18N ("Specify the calibration file to use");
s->opt[OPT_CALIBRATION_FILE].type = SANE_TYPE_STRING;
s->opt[OPT_CALIBRATION_FILE].unit = SANE_UNIT_NONE;
s->opt[OPT_CALIBRATION_FILE].size = PATH_MAX;
s->opt[OPT_CALIBRATION_FILE].cap = SANE_CAP_SOFT_DETECT | SANE_CAP_SOFT_SELECT | SANE_CAP_ADVANCED;
s->opt[OPT_CALIBRATION_FILE].constraint_type = SANE_CONSTRAINT_NONE;
s->val[OPT_CALIBRATION_FILE].s = NULL;
/* disable option if ran as root */
#ifdef HAVE_GETUID
if(geteuid()==0)
{
DISABLE (OPT_CALIBRATION_FILE);
}
#endif
/* 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");
@ -6230,7 +6248,7 @@ probe_genesys_devices (void)
/**
* reads previously cached calibration data
* from file
* from file define in dev->calib_file
*/
SANE_Status
sanei_genesys_read_calibration (Genesys_Device * dev)
@ -6242,6 +6260,8 @@ sanei_genesys_read_calibration (Genesys_Device * dev)
SANE_Status status=SANE_STATUS_GOOD;
DBGSTART;
/* open calibration cache file */
fp = fopen (dev->calib_file, "rb");
if (!fp)
{
@ -6269,6 +6289,15 @@ sanei_genesys_read_calibration (Genesys_Device * dev)
return SANE_STATUS_INVAL;
}
/* clear device calibration cache */
while(dev->calibration_cache!=NULL)
{
cache=dev->calibration_cache;
dev->calibration_cache=dev->calibration_cache->next;
free(cache);
}
/* loop on cache records in file */
while (!feof (fp) && status==SANE_STATUS_GOOD)
{
DBG (DBG_info, "sanei_genesys_read_calibration: reading one record\n");
@ -6835,6 +6864,7 @@ sane_open (SANE_String_Const devicename, SANE_Handle * handle)
sprintf (tmp_str, "%s/.sane/%s.cal", ptr, s->dev->model->name);
}
s->val[OPT_CALIBRATION_FILE].s = strdup (tmp_str);
s->dev->calib_file = strdup (tmp_str);
DBG (DBG_info, "Calibration filename set to:\n");
DBG (DBG_info, ">%s<\n", s->dev->calib_file);
@ -7024,12 +7054,15 @@ get_option_value (Genesys_Scanner * s, int option, void *val)
case OPT_CUSTOM_GAMMA:
*(SANE_Word *) val = s->val[option].w;
break;
/* string options: */
case OPT_MODE:
case OPT_COLOR_FILTER:
case OPT_CALIBRATION_FILE:
case OPT_SOURCE:
strcpy (val, s->val[option].s);
break;
/* word array options */
case OPT_GAMMA_VECTOR:
table = (SANE_Word *) val;
@ -7104,6 +7137,47 @@ get_option_value (Genesys_Scanner * s, int option, void *val)
return status;
}
/** @brief set calibration file value
* Set calibration file value. Load new cache values from file if it exists,
* else creates the file*/
static SANE_Status set_calibration_value (Genesys_Scanner * s, int option, void *val)
{
SANE_Status status=SANE_STATUS_GOOD;
char *tmp;
Genesys_Calibration_Cache *cache;
Genesys_Device *dev=s->dev;
/* try to load file */
tmp=dev->calib_file;
dev->calib_file=val;
status=sanei_genesys_read_calibration (dev);
/* file exists but is invalid */
if (status!=SANE_STATUS_IO_ERROR && status!=SANE_STATUS_GOOD)
{
dev->calib_file=tmp;
return status;
}
/* we can set no file name value */
if (s->val[option].s)
free (s->val[option].s);
s->val[option].s = strdup (val);
if (tmp)
free (tmp);
dev->calib_file = strdup (val);
/* clear device calibration cache */
while(dev->calibration_cache!=NULL)
{
cache=dev->calibration_cache;
dev->calibration_cache=dev->calibration_cache->next;
free(cache);
}
return SANE_STATUS_GOOD;
}
/* sets an option , called by sane_control_option */
static SANE_Status
set_option_value (Genesys_Scanner * s, int option, void *val,
@ -7291,6 +7365,9 @@ set_option_value (Genesys_Scanner * s, int option, void *val,
s->val[option].s = strdup (val);
RIE (calc_parameters (s));
break;
case OPT_CALIBRATION_FILE:
RIE(set_calibration_value (s, option, val));
break;
case OPT_LAMP_OFF_TIME:
if (*(SANE_Word *) val != s->val[option].w)
{

Wyświetl plik

@ -109,6 +109,7 @@ enum Genesys_Option
OPT_DISABLE_DYNAMIC_LINEART,
OPT_DISABLE_INTERPOLATION,
OPT_COLOR_FILTER,
OPT_CALIBRATION_FILE,
OPT_SENSOR_GROUP,
OPT_SCAN_SW,

Wyświetl plik

@ -103,6 +103,20 @@ selected.
The lamp will be turned off during the scan. Calibration is still done with lamp on.
.RE
.B \-\-clear\-calibration
.RS
Clear calibration cache data, triggering a new calibration for the device when the
next scan will happen.
.RE
.B \-\-calibration\-file
.RS
Specify the calibration file name to use. At least the directory containing the file
must exist, since it won't be created. This allow to handle the case of several identical devices
that would otherwise use the same calibration data. This option is disabled if the backend is ran
as root.
.RE
.PP
Additionally, several 'software' options are exposed by the backend. These
are reimplementations of features provided natively by larger scanners, but

Wyświetl plik

@ -2415,7 +2415,7 @@ msgstr "Démarrer la calibration avec la feuille spéciale"
#: ../backend/genesys.c:6414 ../backend/gt68xx.c:809
#, no-c-format
msgid "Clear calibration"
msgstr "Annuler la calibration"
msgstr "Effacer la calibration"
#: ../backend/genesys.c:6415 ../backend/gt68xx.c:810
#, no-c-format