Added threshold option for black & white.

DEVEL_2_0_BRANCH-1
Frank Zago 2002-08-23 01:35:31 +00:00
rodzic 6259eb59d9
commit fb939e9b4c
2 zmienionych plików z 29 dodań i 2 usunięć

Wyświetl plik

@ -48,7 +48,7 @@
/*--------------------------------------------------------------------------*/
#define BUILD 0 /* 2002/04/21 */
#define BUILD 1 /* 2002/08/06 */
#define BACKEND_NAME teco3
#define TECO_CONFIG_FILE "teco3.conf"
@ -132,6 +132,14 @@ static const int dither_val[] = {
/*--------------------------------------------------------------------------*/
static const SANE_Range threshold_range = {
0, /* minimum */
255, /* maximum */
0 /* quantization */
};
/*--------------------------------------------------------------------------*/
/* Define the supported scanners and their characteristics. */
static const struct scanners_supported scanners[] = {
{
@ -501,14 +509,17 @@ teco_set_window (Teco_Scanner * dev)
switch (dev->scan_mode)
{
case TECO_BW:
window[31] = dev->val[OPT_THRESHOLD].w;
window[33] = 0x00;
i = get_string_list_index (dither_list, dev->val[OPT_DITHER].s);
window[36] = dither_val[i];
break;
case TECO_GRAYSCALE:
window[31] = 0x80;
window[33] = 0x02;
break;
case TECO_COLOR:
window[31] = 0x80;
window[33] = 0x05;
break;
}
@ -517,7 +528,6 @@ teco_set_window (Teco_Scanner * dev)
window[34] = dev->depth;
/* Unknown - invariants */
window[31] = 0x80;
window[37] = 0x80;
switch (dev->def->tecoref)
@ -1032,6 +1042,18 @@ teco_init_options (Teco_Scanner * dev)
dev->opt[OPT_GAMMA_VECTOR_GRAY].constraint.range = &gamma_range;
dev->val[OPT_GAMMA_VECTOR_GRAY].wa = dev->gamma_GRAY;
/* Threshold */
dev->opt[OPT_THRESHOLD].name = SANE_NAME_THRESHOLD;
dev->opt[OPT_THRESHOLD].title = SANE_TITLE_THRESHOLD;
dev->opt[OPT_THRESHOLD].desc = SANE_DESC_THRESHOLD;
dev->opt[OPT_THRESHOLD].type = SANE_TYPE_INT;
dev->opt[OPT_THRESHOLD].unit = SANE_UNIT_NONE;
dev->opt[OPT_THRESHOLD].size = sizeof (SANE_Int);
dev->opt[OPT_THRESHOLD].cap |= SANE_CAP_INACTIVE;
dev->opt[OPT_THRESHOLD].constraint_type = SANE_CONSTRAINT_RANGE;
dev->opt[OPT_THRESHOLD].constraint.range = &threshold_range;
dev->val[OPT_THRESHOLD].w = 128;
/* preview */
dev->opt[OPT_PREVIEW].name = SANE_NAME_PREVIEW;
dev->opt[OPT_PREVIEW].title = SANE_TITLE_PREVIEW;
@ -1678,6 +1700,7 @@ sane_control_option (SANE_Handle handle, SANE_Int option,
case OPT_TL_X:
case OPT_BR_X:
case OPT_CUSTOM_GAMMA:
case OPT_THRESHOLD:
case OPT_PREVIEW:
*(SANE_Word *) val = dev->val[option].w;
return SANE_STATUS_GOOD;
@ -1724,6 +1747,7 @@ sane_control_option (SANE_Handle handle, SANE_Int option,
case OPT_BR_Y:
case OPT_TL_X:
case OPT_BR_X:
case OPT_THRESHOLD:
case OPT_RESOLUTION:
if (info)
{
@ -1757,12 +1781,14 @@ sane_control_option (SANE_Handle handle, SANE_Int option,
dev->opt[OPT_GAMMA_VECTOR_G].cap |= SANE_CAP_INACTIVE;
dev->opt[OPT_GAMMA_VECTOR_B].cap |= SANE_CAP_INACTIVE;
dev->opt[OPT_GAMMA_VECTOR_GRAY].cap |= SANE_CAP_INACTIVE;
dev->opt[OPT_THRESHOLD].cap |= SANE_CAP_INACTIVE;
if (strcmp (dev->val[OPT_MODE].s, BLACK_WHITE_STR) == 0)
{
dev->depth = 8;
dev->scan_mode = TECO_BW;
dev->opt[OPT_DITHER].cap &= ~SANE_CAP_INACTIVE;
dev->opt[OPT_THRESHOLD].cap &= ~SANE_CAP_INACTIVE;
}
else if (strcmp (dev->val[OPT_MODE].s, GRAY_STR) == 0)
{

Wyświetl plik

@ -258,6 +258,7 @@ enum Teco_Option
OPT_GAMMA_VECTOR_G, /* Custom Green Gamma table */
OPT_GAMMA_VECTOR_B, /* Custom Blue Gamma table */
OPT_GAMMA_VECTOR_GRAY, /* Custom Grayscale Gamma table */
OPT_THRESHOLD, /* Threshold */
OPT_DITHER,
OPT_PREVIEW,