]> gitweb.hhaalo.de Git - sane-kds-s2000w-net.git/commitdiff
add height in pixel
authorBastian Dehn <hhaalo@arcor.de>
Sun, 23 Feb 2025 11:44:02 +0000 (12:44 +0100)
committerBastian Dehn <hhaalo@arcor.de>
Thu, 6 Mar 2025 20:44:51 +0000 (21:44 +0100)
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 5f3f4a0c0802ac2d4b9ed854ae47c0b9e0b3b116..379bc8a928bc83db970022aa227eccc911e8414d 100644 (file)
@@ -132,7 +132,6 @@ void _kds_s2000w_handler_opts_set_offset_x_range(json_object* config)
 
        SANE_Range* range = (SANE_Range*) image_offset_x->constraint.range;
 
-       range->min = 0;
        range->max = kds_s2000w_handler_opts_calc_inch_to_pixel(dpi, OFFSET_X_MAX_INCH);
        range->quant = kds_s2000w_handler_opts_calc_pixel_quant(dpi);
 }
@@ -146,7 +145,6 @@ void _kds_s2000w_handler_opts_set_offset_y_range(json_object* config)
 
        SANE_Range* range = (SANE_Range*) image_offset_x->constraint.range;
 
-       range->min = 0;
        range->max = kds_s2000w_handler_opts_calc_inch_to_pixel(dpi, OFFSET_Y_MAX_INCH);
        range->quant = kds_s2000w_handler_opts_calc_pixel_quant(dpi);
 }
@@ -160,11 +158,24 @@ void _kds_s2000w_handler_opts_set_image_width_range(json_object* config)
 
        SANE_Range* range = (SANE_Range*) image_offset_x->constraint.range;
 
-       range->min = 0;
        range->max = kds_s2000w_handler_opts_calc_inch_to_pixel(dpi, MAX_IMAGE_WIDTH_INCH);
        range->quant = kds_s2000w_handler_opts_calc_pixel_quant(dpi);
 }
 
+void _kds_s2000w_handler_opts_set_image_height_range(json_object* config)
+{
+       SANE_Option_Descriptor* image_offset_x = kds_s2000w_option_descriptors_get_by_name(SANE_NAME_PAGE_HEIGHT);
+
+       json_object* object_value = json_object_object_get(config, "DPI");
+       int32_t dpi = json_object_get_int(object_value);
+       object_value = json_object_object_get(config, "MaxDocumentLength");
+       int32_t max_document_length_inch = json_object_get_int(object_value);
+
+       SANE_Range* range = (SANE_Range*) image_offset_x->constraint.range;
+
+       range->max = kds_s2000w_handler_opts_calc_inch_to_pixel(dpi, max_document_length_inch);
+       range->quant = kds_s2000w_handler_opts_calc_pixel_quant(dpi);
+}
 
 void _kds_s2000w_handler_opts_set_enable_suboptions_cropping_image(json_object* config)
 {
@@ -174,11 +185,12 @@ void _kds_s2000w_handler_opts_set_enable_suboptions_cropping_image(json_object*
        SANE_Option_Descriptor* image_offset_x = kds_s2000w_option_descriptors_get_by_name(SANE_NAME_SCAN_TL_X);
        SANE_Option_Descriptor* image_offset_y = kds_s2000w_option_descriptors_get_by_name(SANE_NAME_SCAN_TL_Y);
        SANE_Option_Descriptor* image_width = kds_s2000w_option_descriptors_get_by_name(SANE_NAME_PAGE_WIDTH);
-       SANE_Option_Descriptor* image_height = kds_s2000w_option_descriptors_get_by_name("image-height");
+       SANE_Option_Descriptor* image_height = kds_s2000w_option_descriptors_get_by_name(SANE_NAME_PAGE_HEIGHT);
 
        _kds_s2000w_handler_opts_set_offset_x_range(config);
        _kds_s2000w_handler_opts_set_offset_y_range(config);
        _kds_s2000w_handler_opts_set_image_width_range(config);
+       _kds_s2000w_handler_opts_set_image_height_range(config);
 
        if (strcmp(cropping_image_value, "PartialDocument") == 0) {
                image_offset_x->cap |= SANE_CAP_SOFT_SELECT;
@@ -382,8 +394,7 @@ void kds_s2000w_handler_opts_get_option(handler* h, uint32_t option, void* value
                        _kds_s2000w_handler_opts_get_pixel_value_from_inch(config, "ImageWidth", value);
                        break;
                case 12:
-                       value_object = json_object_object_get(config, "ImageHeight");
-                       _kds_s2000w_handler_opts_write_int_value(value_object, value);
+                       _kds_s2000w_handler_opts_get_pixel_value_from_inch(config, "ImageHeight", value);
                        break;
                case 14:
                        value_object = json_object_object_get(config, "ForegroundBoldnessMode");
@@ -580,8 +591,7 @@ void kds_s2000w_handler_opts_set_option(handler* h, uint32_t option, void* value
                        _kds_s2000w_handler_opts_set_inch_value_from_pixel(config, "ImageWidth", value);
                        break;
                case 12:
-                       value_object = json_object_object_get(config, "ImageHeight");
-                       _kds_s2000w_handler_opts_write_int_value_to_json(value_object, value);
+                       _kds_s2000w_handler_opts_set_inch_value_from_pixel(config, "ImageHeight", value);
                        break;
                case 14:
                        value_object = json_object_object_get(config, "ForegroundBoldnessMode");
index bd2dada14254bd5b19ef8b968fabc1859dc90220..57638bb062581b3f7ba1c786df116868fab5bb87 100644 (file)
@@ -1017,16 +1017,16 @@ 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 = 200;
+       constraint->max = 8000;
+       constraint->quant = 20;
 
        SANE_Option_Descriptor descriptor = {
-               "image-height",
-               "Image Height",
-               "Image Height",
+               SANE_NAME_PAGE_HEIGHT,
+               SANE_TITLE_PAGE_HEIGHT,
+               SANE_DESC_PAGE_HEIGHT,
                SANE_TYPE_INT,
-               SANE_UNIT_NONE,
+               SANE_UNIT_PIXEL,
                sizeof(SANE_Int),
                SANE_CAP_SOFT_DETECT | SANE_CAP_SOFT_SELECT,
                SANE_CONSTRAINT_RANGE,
index f071606d11725cbf19f12d239697abac15712678..c34fcec3f7618692bfcd13d58fdceea02d0b51e2 100644 (file)
@@ -174,7 +174,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, 200);
 
        kds_s2000w_handler_free(h);
        h = NULL;
index f0498f28a0a7a43c7dc33c36a74d92fd07375466..fc70f10f99f851c33487bddfe35b38cf42c2c788 100644 (file)
@@ -225,17 +225,17 @@ void kds_s2000w_option_get_descriptor_twelve_test()
 {
        SANE_Option_Descriptor* option = kds_s2000w_option_descriptors_get(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_PAGE_HEIGHT, option->name);
+       assert_string_equal(SANE_TITLE_PAGE_HEIGHT, option->title);
+       assert_string_equal(SANE_DESC_PAGE_HEIGHT, 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, 200);
+       assert_int_equal(option->constraint.range->max, 8000);
+       assert_int_equal(option->constraint.range->quant, 20);
 }
 
 void kds_s2000w_option_get_descriptor_thirdteen_test()