From a1a44fc359fb6d0b8892ecb7caed9f643c7bb4cd Mon Sep 17 00:00:00 2001 From: Bastian Dehn Date: Tue, 7 Oct 2025 19:24:16 +0200 Subject: [PATCH] add br x --- src/kds_s2000w_handler_opts.c | 22 ++++++++++++++++++++++ src/kds_s2000w_option_descriptors.c | 14 +++++++------- tests/kds_s2000w_net_get_opt_tests.c | 2 +- tests/kds_s2000w_option_descriptor_tests.c | 14 +++++++------- 4 files changed, 37 insertions(+), 15 deletions(-) diff --git a/src/kds_s2000w_handler_opts.c b/src/kds_s2000w_handler_opts.c index 4536887..7e8353b 100644 --- a/src/kds_s2000w_handler_opts.c +++ b/src/kds_s2000w_handler_opts.c @@ -372,6 +372,17 @@ void kds_s2000w_handler_opts_get_option(handler* h, uint32_t option, void* value return; } + if (strcmp(descriptor->config_name, IMAGE_WIDTH) == 0) { + int32_t* int_value = (int32_t*) value; + int32_t tenth_inch_width = json_object_get_int(value_object); + value_object = json_object_object_get(config, IMAGE_OFFSET_X); + int32_t tenth_inch_offset_x = json_object_get_int(value_object); + uint32_t width_pixel = kds_s2000w_pixel_converter_tenth_inch_to_pixel(GUI_DPI, tenth_inch_width); + uint32_t offset_x_pixel = kds_s2000w_pixel_converter_tenth_inch_to_pixel(GUI_DPI, tenth_inch_offset_x); + *int_value = offset_x_pixel + width_pixel; + return; + } + _kds_s2000w_handler_opts_write_value(value_object, descriptor->descriptor->type, value); } @@ -414,6 +425,17 @@ void kds_s2000w_handler_opts_set_option(handler* h, uint32_t option, void* value json_object_set_int(value_object, tenth_inch); } + if (strcmp(descriptor->config_name, IMAGE_WIDTH) == 0) { + int32_t* int_value = (int32_t*) value; + value_object = json_object_object_get(config, IMAGE_OFFSET_X); + int32_t tenth_inch_offset_x = json_object_get_int(value_object); + uint32_t offset_x_pixel = kds_s2000w_pixel_converter_tenth_inch_to_pixel(GUI_DPI, tenth_inch_offset_x); + uint32_t width_pixel = *int_value - offset_x_pixel; + uint32_t tenth_inch_width = kds_s2000w_pixel_converter_pixel_to_tenth_inch(GUI_DPI, width_pixel); + value_object = json_object_object_get(config, descriptor->config_name); + json_object_set_int(value_object, tenth_inch_width); + } + if (strcmp(descriptor->config_name, RESET) == 0) { _kds_s2000w_handler_opts_set_option_to_default(h); config = json_object_object_get(h->current_scanner_config, "Configuration"); diff --git a/src/kds_s2000w_option_descriptors.c b/src/kds_s2000w_option_descriptors.c index c8f8ab9..ef5b8d0 100644 --- a/src/kds_s2000w_option_descriptors.c +++ b/src/kds_s2000w_option_descriptors.c @@ -298,17 +298,17 @@ SANE_Option_Descriptor* _kds_s2000w_option_descriptor_image_width() kds_s2000w_debug_printf(ALL, "kds_s2000w_option_descriptor_image_width"); SANE_Range* constraint = malloc(sizeof(SANE_Range)); - constraint->min = 10; - constraint->max = 85; - constraint->quant = 1; + constraint->min = 300; + constraint->max = 2550; + constraint->quant = 30; SANE_Option_Descriptor* descriptor = malloc(sizeof(SANE_Option_Descriptor)); - descriptor->name = "image-width"; - descriptor->title = "Image Width"; - descriptor->desc = "Image Width"; + descriptor->name = SANE_NAME_SCAN_BR_X; + descriptor->title = SANE_TITLE_SCAN_BR_X; + descriptor->desc = SANE_DESC_SCAN_BR_X; descriptor->type = SANE_TYPE_INT; - descriptor->unit = SANE_UNIT_NONE; + descriptor->unit = SANE_UNIT_PIXEL; descriptor->size = sizeof(SANE_Int); descriptor->cap = SANE_CAP_SOFT_DETECT | SANE_CAP_SOFT_SELECT; descriptor->constraint_type = SANE_CONSTRAINT_RANGE; diff --git a/tests/kds_s2000w_net_get_opt_tests.c b/tests/kds_s2000w_net_get_opt_tests.c index da2640f..92e1816 100644 --- a/tests/kds_s2000w_net_get_opt_tests.c +++ b/tests/kds_s2000w_net_get_opt_tests.c @@ -242,7 +242,7 @@ void sane_kds_s2000w_net_control_get_option_eleven_test(void** state) sane_kds_s2000w_net_control_option(h, 11, SANE_ACTION_GET_VALUE, &value, NULL); - assert_int_equal(value, 10); + assert_int_equal(value, 300); kds_s2000w_handler_free(h); h = NULL; diff --git a/tests/kds_s2000w_option_descriptor_tests.c b/tests/kds_s2000w_option_descriptor_tests.c index 25328a2..6002a33 100644 --- a/tests/kds_s2000w_option_descriptor_tests.c +++ b/tests/kds_s2000w_option_descriptor_tests.c @@ -210,17 +210,17 @@ void kds_s2000w_option_get_descriptor_eleven_test() { SANE_Option_Descriptor* option = kds_s2000w_option_descriptors_get_by_number(11); - assert_string_equal("image-width", option->name); - assert_string_equal("Image Width", option->title); - assert_string_equal("Image Width", option->desc); + assert_string_equal(SANE_NAME_SCAN_BR_X, option->name); + assert_string_equal(SANE_TITLE_SCAN_BR_X, option->title); + assert_string_equal(SANE_DESC_SCAN_BR_X, option->desc); assert_int_equal(SANE_TYPE_INT, option->type); - assert_int_equal(SANE_UNIT_NONE, option->unit); + assert_int_equal(SANE_UNIT_PIXEL, option->unit); assert_int_equal(sizeof(SANE_Int), option->size); assert_int_equal(SANE_CAP_SOFT_DETECT | SANE_CAP_SOFT_SELECT, option->cap); assert_int_equal(SANE_CONSTRAINT_RANGE, option->constraint_type); - assert_int_equal(option->constraint.range->min, 10); - assert_int_equal(option->constraint.range->max, 85); - assert_int_equal(option->constraint.range->quant, 1); + assert_int_equal(option->constraint.range->min, 300); + assert_int_equal(option->constraint.range->max, 2550); + assert_int_equal(option->constraint.range->quant, 30); } void kds_s2000w_option_get_descriptor_twelve_test() -- 2.47.3