]> gitweb.hhaalo.de Git - sane-kds-s2000w-net.git/commitdiff
fix set width
authorBastian Dehn <hhaalo@arcor.de>
Thu, 20 Mar 2025 16:50:12 +0000 (17:50 +0100)
committerBastian Dehn <hhaalo@arcor.de>
Thu, 20 Mar 2025 17:07:27 +0000 (18:07 +0100)
src/kds_s2000w_handler_opts.c

index 6754517bff96c3f66c60a8b3b9bda9a3ead44a5c..7309591b9e2d86b12098343872ba43b54c0347c0 100644 (file)
@@ -310,14 +310,16 @@ void _kds_s2000w_handler_opts_set_width(json_object* config, handler* h)
        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, "ImageOffsetX");
-       int32_t tl_x = json_object_get_int(object_value);
+       int32_t tl_x_inch = json_object_get_int(object_value);
+       int32_t tl_x_pixel = kds_s2000w_handler_opts_calc_inch_to_pixel(dpi, tl_x_inch);
+       int32_t br_x_pixel = kds_s2000w_handler_opts_calc_inch_to_pixel(dpi, h->br->x);
        SANE_Option_Descriptor* width_option = kds_s2000w_option_descriptors_get_by_name(SANE_NAME_PAGE_WIDTH);
 
-       int32_t width_pixel = kds_s2000w_handler_opts_calc_diff(width_option->constraint.range->max, tl_x, h->br->x);
+       int32_t width_pixel = kds_s2000w_handler_opts_calc_diff(width_option->constraint.range->max, tl_x_pixel, br_x_pixel);
        int32_t width_inch = kds_s2000w_handler_opts_calc_pixel_to_inch(dpi, width_pixel);
 
        object_value = json_object_object_get(config, "ImageWidth");
-       _kds_s2000w_handler_opts_write_int_value(object_value, (void*) &width_inch);
+       _kds_s2000w_handler_opts_write_int_value_to_json(object_value, (void*) &width_inch);
 }
 
 void _kds_s2000w_handler_opts_set_height(json_object* config, handler* h)
@@ -325,14 +327,16 @@ void _kds_s2000w_handler_opts_set_height(json_object* config, handler* h)
        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, "ImageOffsetY");
-       int32_t tl_y = json_object_get_int(object_value);
+       int32_t tl_y_inch = json_object_get_int(object_value);
+       int32_t tl_y_pixel = kds_s2000w_handler_opts_calc_inch_to_pixel(dpi, tl_y_inch);
+       int32_t br_y_pixel = kds_s2000w_handler_opts_calc_inch_to_pixel(dpi, h->br->y);
        SANE_Option_Descriptor* height_option = kds_s2000w_option_descriptors_get_by_name(SANE_NAME_PAGE_HEIGHT);
 
-       int32_t height_pixel = kds_s2000w_handler_opts_calc_diff(height_option->constraint.range->max, tl_y, h->br->y);
+       int32_t height_pixel = kds_s2000w_handler_opts_calc_diff(height_option->constraint.range->max, tl_y_pixel, br_y_pixel);
        int32_t height_inch = kds_s2000w_handler_opts_calc_pixel_to_inch(dpi, height_pixel);
 
        object_value = json_object_object_get(config, "ImageHeight");
-       _kds_s2000w_handler_opts_write_int_value(object_value, (void*) &height_inch);
+       _kds_s2000w_handler_opts_write_int_value_to_json(object_value, (void*) &height_inch);
 }
 
 int32_t _kds_s2000w_handler_opts_inch_to_pixel(json_object* config, int32_t inch)