]> gitweb.hhaalo.de Git - sane-kds-s2000w-net.git/commitdiff
add change image offset x to tl x
authorBastian Dehn <hhaalo@arcor.de>
Tue, 7 Oct 2025 16:40:32 +0000 (18:40 +0200)
committerBastian Dehn <hhaalo@arcor.de>
Tue, 7 Oct 2025 16:40:32 +0000 (18:40 +0200)
src/kds_s2000w_handler_opts.c
src/kds_s2000w_option_descriptors.c
tests/kds_s2000w_option_descriptor_tests.c

index 2acd93083733bdf204c492824c5a4be6623e3693..131c4b94ae8f472917331ebb505ca738fc8cb925 100644 (file)
@@ -4,8 +4,10 @@
 #include "kds_s2000w_option_descriptors.h"
 #include "kds_s2000w_client.h"
 #include "kds_s2000w_debug.h"
+#include "kds_s2000w_pixel_converter.h"
 
 #define AUTOSTART_ON 1
+#define GUI_DPI 300
 
 void _kds_s2000w_handler_opts_write_value_to_json(json_object* value_object, SANE_Value_Type value_type, void* value)
 {
@@ -361,6 +363,14 @@ void kds_s2000w_handler_opts_get_option(handler* h, uint32_t option, void* value
                return;
        }
 
+       if (strcmp(descriptor->config_name, IMAGE_OFFSET_X) == 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);
+               *int_value = pixel;
+               return;
+       }
+
        _kds_s2000w_handler_opts_write_value(value_object, descriptor->descriptor->type, value);
 }
 
@@ -396,6 +406,12 @@ 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) {
+               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);
+       }
+
        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 fcc879205dd5fc9d41d3e8d5b116dc13d1a7793b..43d8463b74ed4873b0b9419d56c02375ed365ab5 100644 (file)
@@ -251,16 +251,16 @@ SANE_Option_Descriptor* _kds_s2000w_option_descriptor_image_offset_x()
 
        SANE_Range* constraint = malloc(sizeof(SANE_Range));
        constraint->min = 0;
-       constraint->max = 75;
-       constraint->quant = 1;
+       constraint->max = 2250;
+       constraint->quant = 30;
 
        SANE_Option_Descriptor* descriptor = malloc(sizeof(SANE_Option_Descriptor));
 
-       descriptor->name = "image-offset-x";
-       descriptor->title = "Image Offset X";
-       descriptor->desc = "Image Offset X";
+       descriptor->name = SANE_NAME_SCAN_TL_X;
+       descriptor->title = SANE_TITLE_SCAN_TL_X;
+       descriptor->desc = SANE_DESC_SCAN_TL_X;
        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 c87159b2d028edb45bccd26ac5f14b7a0f76582d..826febe68b04f93b6eb52110767c6fb5584665d0 100644 (file)
@@ -176,17 +176,17 @@ void kds_s2000w_option_get_descriptor_nine_test()
 {
        SANE_Option_Descriptor* option = kds_s2000w_option_descriptors_get_by_number(9);
 
-       assert_string_equal("image-offset-x", option->name);
-       assert_string_equal("Image Offset X", option->title);
-       assert_string_equal("Image Offset X", option->desc);
+       assert_string_equal(SANE_NAME_SCAN_TL_X, option->name);
+       assert_string_equal(SANE_TITLE_SCAN_TL_X, option->title);
+       assert_string_equal(SANE_DESC_SCAN_TL_X, 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, 75);
-       assert_int_equal(option->constraint.range->quant, 1);
+       assert_int_equal(option->constraint.range->max, 2250);
+       assert_int_equal(option->constraint.range->quant, 30);
 }
 
 void kds_s2000w_option_get_descriptor_ten_test()