From 424b4e4b0d699c2a0b7233207a30673c36a974fc Mon Sep 17 00:00:00 2001 From: Bastian Dehn Date: Sun, 26 Oct 2025 15:24:05 +0100 Subject: [PATCH] change set min width and height --- src/kds_s2000w_handler_opts.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/kds_s2000w_handler_opts.c b/src/kds_s2000w_handler_opts.c index 41e21af..dbd6b9c 100644 --- a/src/kds_s2000w_handler_opts.c +++ b/src/kds_s2000w_handler_opts.c @@ -156,6 +156,17 @@ int32_t _kds_s2000w_handler_opts_get_height(handler_t* h, json_object* value_obj return GOOD; } +void _kds_s2000w_handler_opts_set_width_or_height_min(option_descriptor_t* descriptor, void* value) +{ + if (strcmp(descriptor->config_name, IMAGE_WIDTH) != 0 + && strcmp(descriptor->config_name, IMAGE_HEIGHT) != 0) + return; + + int32_t* int_value = (int32_t*) value; + if (*int_value < descriptor->descriptor->constraint.range->min) + *int_value = descriptor->descriptor->constraint.range->min; +} + void _kds_s2000w_handler_opts_set_options(handler_t* h) { const char* json_string = json_object_to_json_string_ext(h->scanner_config, JSON_C_TO_STRING_PLAIN); @@ -532,7 +543,6 @@ int32_t kds_s2000w_handler_opts_get_option(handler_t* h, uint32_t option, void* return _kds_s2000w_handler_opts_get_zero_option(value); json_object* value_object = json_object_object_get(h->scanner_config, descriptor->config_name); - if (strcmp(descriptor->config_name, IMAGE_OFFSET_X) == 0) return _kds_s2000w_handler_opts_get_image_offset_x(h, value_object, value); @@ -558,12 +568,7 @@ int32_t kds_s2000w_handler_opts_set_option(handler_t* h, uint32_t option, void* option_descriptor_t* descriptor = kds_s2000w_option_descriptors_full_get_by_number(option); json_object* value_object = json_object_object_get(h->scanner_config, descriptor->config_name); - if (strcmp(descriptor->config_name, IMAGE_WIDTH) == 0 - || strcmp(descriptor->config_name, IMAGE_HEIGHT) == 0) { - int32_t* int_value = (int32_t*) value; - if (*int_value < descriptor->descriptor->constraint.range->min) - *int_value = descriptor->descriptor->constraint.range->min; - } + _kds_s2000w_handler_opts_set_width_or_height_min(descriptor, value); _kds_s2000w_handler_opts_set_offset_x(descriptor, h, value); _kds_s2000w_handler_opts_set_width(descriptor, h, value); -- 2.47.3