From c140ae8a8fb9f7102c83fe7033841638793d515e Mon Sep 17 00:00:00 2001 From: Bastian Dehn Date: Tue, 7 Oct 2025 18:46:31 +0200 Subject: [PATCH] add tl y option with pixel --- src/kds_s2000w_handler_opts.c | 6 ++++-- src/kds_s2000w_option_descriptors.c | 12 ++++++------ tests/kds_s2000w_option_descriptor_tests.c | 12 ++++++------ 3 files changed, 16 insertions(+), 14 deletions(-) diff --git a/src/kds_s2000w_handler_opts.c b/src/kds_s2000w_handler_opts.c index 131c4b9..4536887 100644 --- a/src/kds_s2000w_handler_opts.c +++ b/src/kds_s2000w_handler_opts.c @@ -363,7 +363,8 @@ void kds_s2000w_handler_opts_get_option(handler* h, uint32_t option, void* value return; } - if (strcmp(descriptor->config_name, IMAGE_OFFSET_X) == 0) { + if (strcmp(descriptor->config_name, IMAGE_OFFSET_X) == 0 + || strcmp(descriptor->config_name, IMAGE_OFFSET_Y) == 0) { int32_t* int_value = (int32_t*) value; int32_t tenth_inch = json_object_get_int(value_object); uint32_t pixel = kds_s2000w_pixel_converter_tenth_inch_to_pixel(GUI_DPI, tenth_inch); @@ -406,7 +407,8 @@ void kds_s2000w_handler_opts_set_option(handler* h, uint32_t option, void* value h->current_scan_status->feeder = Automatic; } - if (strcmp(descriptor->config_name, IMAGE_OFFSET_X) == 0) { + if (strcmp(descriptor->config_name, IMAGE_OFFSET_X) == 0 + || strcmp(descriptor->config_name, IMAGE_OFFSET_Y) == 0) { int32_t* int_value = (int32_t*) value; uint32_t tenth_inch = kds_s2000w_pixel_converter_pixel_to_tenth_inch(GUI_DPI, *int_value); json_object_set_int(value_object, tenth_inch); diff --git a/src/kds_s2000w_option_descriptors.c b/src/kds_s2000w_option_descriptors.c index 43d8463..c8f8ab9 100644 --- a/src/kds_s2000w_option_descriptors.c +++ b/src/kds_s2000w_option_descriptors.c @@ -275,16 +275,16 @@ SANE_Option_Descriptor* _kds_s2000w_option_descriptor_image_offset_y() SANE_Range* constraint = malloc(sizeof(SANE_Range)); constraint->min = 0; - constraint->max = 390; - constraint->quant = 1; + constraint->max = 3900; + constraint->quant = 30; SANE_Option_Descriptor* descriptor = malloc(sizeof(SANE_Option_Descriptor)); - descriptor->name = "image-offset-y"; - descriptor->title = "Image Offset Y"; - descriptor->desc = "Image Offset Y"; + descriptor->name = SANE_NAME_SCAN_TL_Y; + descriptor->title = SANE_TITLE_SCAN_TL_Y; + descriptor->desc = SANE_DESC_SCAN_TL_Y; 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_option_descriptor_tests.c b/tests/kds_s2000w_option_descriptor_tests.c index 826febe..25328a2 100644 --- a/tests/kds_s2000w_option_descriptor_tests.c +++ b/tests/kds_s2000w_option_descriptor_tests.c @@ -193,17 +193,17 @@ void kds_s2000w_option_get_descriptor_ten_test() { SANE_Option_Descriptor* option = kds_s2000w_option_descriptors_get_by_number(10); - assert_string_equal("image-offset-y", option->name); - assert_string_equal("Image Offset Y", option->title); - assert_string_equal("Image Offset Y", option->desc); + assert_string_equal(SANE_NAME_SCAN_TL_Y, option->name); + assert_string_equal(SANE_TITLE_SCAN_TL_Y, option->title); + assert_string_equal(SANE_DESC_SCAN_TL_Y, 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, 0); - assert_int_equal(option->constraint.range->max, 390); - assert_int_equal(option->constraint.range->quant, 1); + assert_int_equal(option->constraint.range->max, 3900); + assert_int_equal(option->constraint.range->quant, 30); } void kds_s2000w_option_get_descriptor_eleven_test() -- 2.47.3