From ad38bc6ecb80ddeb562841b33258dd53659b1da6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Frings-F=C3=BCrst?= Date: Mon, 24 Aug 2020 18:44:51 +0200 Subject: New upstream version 1.0.31 --- backend/test.c | 113 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 113 insertions(+) (limited to 'backend/test.c') diff --git a/backend/test.c b/backend/test.c index 3ead456..a1e186e 100644 --- a/backend/test.c +++ b/backend/test.c @@ -116,6 +116,12 @@ static SANE_Range int_constraint_range = { 2 }; +static SANE_Range gamma_range = { + 0, + 255, + 1 +}; + static SANE_Range fixed_constraint_range = { SANE_FIX (-42.17), SANE_FIX (32767.9999), @@ -184,6 +190,42 @@ static SANE_Int int_array_constraint_range[] = { 48, 6, 4, 92, 190, 16 }; +#define GAMMA_RED_SIZE 256 +#define GAMMA_GREEN_SIZE 256 +#define GAMMA_BLUE_SIZE 256 +#define GAMMA_ALL_SIZE 4096 +static SANE_Int gamma_red[GAMMA_RED_SIZE]; // initialized in init_options() +static SANE_Int gamma_green[GAMMA_GREEN_SIZE]; +static SANE_Int gamma_blue[GAMMA_BLUE_SIZE]; +static SANE_Int gamma_all[GAMMA_ALL_SIZE]; + +static void +init_gamma_table(SANE_Int *tablePtr, SANE_Int count, SANE_Int max) +{ + for (int i=0; i 0) { + DBG (5, "%s\n", str); + str[0] = '\0'; + } + sprintf (str + strlen(str), " %04X", tablePtr[i]); + } + if (strlen(str) > 0) { + DBG (5, "%s\n", str); + } +} + + static SANE_Int int_array_constraint_word_list[] = { -42, 0, -8, 17, 42, 42 }; @@ -923,6 +965,63 @@ init_options (Test_Device * test_device) test_device->val[opt_int_array_constraint_range].wa = &int_array_constraint_range[0]; + /* opt_gamma_red */ + init_gamma_table(gamma_red, GAMMA_RED_SIZE, gamma_range.max); + od = &test_device->opt[opt_gamma_red]; + od->name = SANE_NAME_GAMMA_VECTOR_R; + od->title = SANE_TITLE_GAMMA_VECTOR_R; + od->desc = SANE_DESC_GAMMA_VECTOR_R; + od->type = SANE_TYPE_INT; + od->unit = SANE_UNIT_NONE; + od->size = 256 * sizeof (SANE_Word); + od->cap = SANE_CAP_SOFT_DETECT | SANE_CAP_SOFT_SELECT | SANE_CAP_ADVANCED; + od->constraint_type = SANE_CONSTRAINT_RANGE; + od->constraint.range = &gamma_range; + test_device->val[opt_gamma_red].wa = &gamma_red[0]; + + /* opt_gamma_green */ + init_gamma_table(gamma_green, GAMMA_GREEN_SIZE, gamma_range.max); + od = &test_device->opt[opt_gamma_green]; + od->name = SANE_NAME_GAMMA_VECTOR_G; + od->title = SANE_TITLE_GAMMA_VECTOR_G; + od->desc = SANE_DESC_GAMMA_VECTOR_G; + od->type = SANE_TYPE_INT; + od->unit = SANE_UNIT_NONE; + od->size = 256 * sizeof (SANE_Word); + od->cap = SANE_CAP_SOFT_DETECT | SANE_CAP_SOFT_SELECT | SANE_CAP_ADVANCED; + od->constraint_type = SANE_CONSTRAINT_RANGE; + od->constraint.range = &gamma_range; + test_device->val[opt_gamma_green].wa = &gamma_green[0]; + + /* opt_gamma_blue */ + init_gamma_table(gamma_blue, GAMMA_BLUE_SIZE, gamma_range.max); + od = &test_device->opt[opt_gamma_blue]; + od->name = SANE_NAME_GAMMA_VECTOR_B; + od->title = SANE_TITLE_GAMMA_VECTOR_B; + od->desc = SANE_DESC_GAMMA_VECTOR_B; + od->type = SANE_TYPE_INT; + od->unit = SANE_UNIT_NONE; + od->size = 256 * sizeof (SANE_Word); + od->cap = SANE_CAP_SOFT_DETECT | SANE_CAP_SOFT_SELECT | SANE_CAP_ADVANCED; + od->constraint_type = SANE_CONSTRAINT_RANGE; + od->constraint.range = &gamma_range; + test_device->val[opt_gamma_blue].wa = &gamma_blue[0]; + + /* opt_gamma_all */ + init_gamma_table(gamma_all, GAMMA_ALL_SIZE, gamma_range.max); + print_gamma_table(gamma_all, GAMMA_ALL_SIZE); + od = &test_device->opt[opt_gamma_all]; + od->name = SANE_NAME_GAMMA_VECTOR; + od->title = SANE_TITLE_GAMMA_VECTOR; + od->desc = SANE_DESC_GAMMA_VECTOR; + od->type = SANE_TYPE_INT; + od->unit = SANE_UNIT_NONE; + od->size = GAMMA_ALL_SIZE * sizeof (SANE_Word); + od->cap = SANE_CAP_SOFT_DETECT | SANE_CAP_SOFT_SELECT | SANE_CAP_ADVANCED; + od->constraint_type = SANE_CONSTRAINT_RANGE; + od->constraint.range = &gamma_range; + test_device->val[opt_gamma_all].wa = &gamma_all[0]; + /* opt_int_array_constraint_word_list */ od = &test_device->opt[opt_int_array_constraint_word_list]; od->name = "int-constraint-array-constraint-word-list"; @@ -2071,11 +2170,21 @@ sane_control_option (SANE_Handle handle, SANE_Int option, SANE_Action action, break; case opt_int_array: /* Word array */ case opt_int_array_constraint_range: + case opt_gamma_red: + case opt_gamma_green: + case opt_gamma_blue: + case opt_gamma_all: case opt_int_array_constraint_word_list: memcpy (test_device->val[option].wa, value, test_device->opt[option].size); DBG (4, "sane_control_option: set option %d (%s) to %p\n", option, test_device->opt[option].name, (void *) value); + if (option == opt_gamma_all) { + print_gamma_table(gamma_all, GAMMA_ALL_SIZE); + } + if (option == opt_gamma_red) { + print_gamma_table(gamma_red, GAMMA_RED_SIZE); + } break; /* options with side-effects */ case opt_print_options: @@ -2298,6 +2407,10 @@ sane_control_option (SANE_Handle handle, SANE_Int option, SANE_Action action, break; case opt_int_array: /* Int array */ case opt_int_array_constraint_range: + case opt_gamma_red: + case opt_gamma_green: + case opt_gamma_blue: + case opt_gamma_all: case opt_int_array_constraint_word_list: memcpy (value, test_device->val[option].wa, test_device->opt[option].size); -- cgit v1.2.3