]> gitweb.hhaalo.de Git - sane-kds-s2000w-net.git/commitdiff
change set min width and height
authorBastian Dehn <hhaalo@arcor.de>
Sun, 26 Oct 2025 14:24:05 +0000 (15:24 +0100)
committerBastian Dehn <hhaalo@arcor.de>
Sun, 26 Oct 2025 14:24:05 +0000 (15:24 +0100)
src/kds_s2000w_handler_opts.c

index 41e21afbd42157d2c06ecf10be20ba7bdd815158..dbd6b9c9bbd21e452030da44ad2d64cabddbc7d8 100644 (file)
@@ -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);