]> gitweb.hhaalo.de Git - sane-kds-s2000w-net.git/commitdiff
add br y
authorBastian Dehn <hhaalo@arcor.de>
Tue, 7 Oct 2025 17:48:35 +0000 (19:48 +0200)
committerBastian Dehn <hhaalo@arcor.de>
Tue, 7 Oct 2025 17:48:35 +0000 (19:48 +0200)
src/kds_s2000w_handler_opts.c
src/kds_s2000w_option_descriptors.c
tests/kds_s2000w_net_get_opt_tests.c
tests/kds_s2000w_option_descriptor_tests.c

index 7e8353b8ca0aaf036bd8cb27b9a9497351b2ae09..c75698f34a11b3f61e281026fc7c57917a518ddc 100644 (file)
@@ -383,6 +383,17 @@ void kds_s2000w_handler_opts_get_option(handler* h, uint32_t option, void* value
                return;
        }
 
+       if (strcmp(descriptor->config_name, IMAGE_HEIGHT) == 0) {
+               int32_t* int_value = (int32_t*) value;
+               int32_t tenth_inch_height = json_object_get_int(value_object);
+               value_object = json_object_object_get(config, IMAGE_OFFSET_Y);
+               int32_t tenth_inch_offset_y = json_object_get_int(value_object);
+               uint32_t height_pixel = kds_s2000w_pixel_converter_tenth_inch_to_pixel(GUI_DPI, tenth_inch_height);
+               uint32_t offset_y_pixel = kds_s2000w_pixel_converter_tenth_inch_to_pixel(GUI_DPI, tenth_inch_offset_y);
+               *int_value = offset_y_pixel + height_pixel;
+               return;
+       }
+
        _kds_s2000w_handler_opts_write_value(value_object, descriptor->descriptor->type, value);
 }
 
@@ -436,6 +447,17 @@ void kds_s2000w_handler_opts_set_option(handler* h, uint32_t option, void* value
                json_object_set_int(value_object, tenth_inch_width);
        }
 
+       if (strcmp(descriptor->config_name, IMAGE_HEIGHT) == 0) {
+               int32_t* int_value = (int32_t*) value;
+               value_object = json_object_object_get(config, IMAGE_OFFSET_Y);
+               int32_t tenth_inch_offset_y = json_object_get_int(value_object);
+               uint32_t offset_y_pixel = kds_s2000w_pixel_converter_tenth_inch_to_pixel(GUI_DPI, tenth_inch_offset_y);
+               uint32_t height_pixel = *int_value - offset_y_pixel;
+               uint32_t tenth_inch_height = kds_s2000w_pixel_converter_pixel_to_tenth_inch(GUI_DPI, height_pixel);
+               value_object = json_object_object_get(config, descriptor->config_name);
+               json_object_set_int(value_object, tenth_inch_height);
+       }
+
        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");
index ef5b8d00c187c535186ec584dc461653f3288b72..9952ed846264b6f36c9c149a08b7f882b1aca383 100644 (file)
@@ -322,17 +322,17 @@ SANE_Option_Descriptor* _kds_s2000w_option_descriptor_image_height()
        kds_s2000w_debug_printf(ALL, "kds_s2000w_option_descriptor_image_height");
 
        SANE_Range* constraint = malloc(sizeof(SANE_Range));
-       constraint->min = 10;
-       constraint->max = 400;
-       constraint->quant = 1;
+       constraint->min = 300;
+       constraint->max = 3900;
+       constraint->quant = 30;
 
        SANE_Option_Descriptor* descriptor = malloc(sizeof(SANE_Option_Descriptor));
 
-       descriptor->name = "image-height";
-       descriptor->title = "Image Height";
-       descriptor->desc = "Image Height";
+       descriptor->name = SANE_NAME_SCAN_BR_Y;
+       descriptor->title = SANE_TITLE_SCAN_BR_Y;
+       descriptor->desc = SANE_DESC_SCAN_BR_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;
index 92e1816fd73aaf3ce22c7a92de68aa3f9e047a87..42f95cc5ee5394768bde94663b2f1fe381a39697 100644 (file)
@@ -257,7 +257,7 @@ void sane_kds_s2000w_net_control_get_option_twelve_test(void** state)
 
        sane_kds_s2000w_net_control_option(h, 12, SANE_ACTION_GET_VALUE, &value, NULL);
 
-       assert_int_equal(value, 10);
+       assert_int_equal(value, 300);
 
        kds_s2000w_handler_free(h);
        h = NULL;
index 6002a33eec335dabd1577993861221f89fc89ea0..c548f5da2f6ac143ff4d4e376c2e79fc102af88a 100644 (file)
@@ -227,17 +227,17 @@ void kds_s2000w_option_get_descriptor_twelve_test()
 {
        SANE_Option_Descriptor* option = kds_s2000w_option_descriptors_get_by_number(12);
 
-       assert_string_equal("image-height", option->name);
-       assert_string_equal("Image Height", option->title);
-       assert_string_equal("Image Height", option->desc);
+       assert_string_equal(SANE_NAME_SCAN_BR_Y, option->name);
+       assert_string_equal(SANE_TITLE_SCAN_BR_Y, option->title);
+       assert_string_equal(SANE_DESC_SCAN_BR_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, 10);
-       assert_int_equal(option->constraint.range->max, 400);
-       assert_int_equal(option->constraint.range->quant, 1);
+       assert_int_equal(option->constraint.range->min, 300);
+       assert_int_equal(option->constraint.range->max, 3900);
+       assert_int_equal(option->constraint.range->quant, 30);
 }
 
 void kds_s2000w_option_get_descriptor_thirdteen_test()