]> gitweb.hhaalo.de Git - sane-kds-s2000w-net.git/commitdiff
add tenth inch to pixel
authorBastian Dehn <hhaalo@arcor.de>
Tue, 7 Oct 2025 16:09:18 +0000 (18:09 +0200)
committerBastian Dehn <hhaalo@arcor.de>
Tue, 7 Oct 2025 16:09:18 +0000 (18:09 +0200)
src/kds_s2000w_pixel_converter.c
src/kds_s2000w_pixel_converter.h
tests/kds_s2000w_pixel_converter_tests.c

index 1cc3c52f01b2646841c10db4a102522ebd2ffd18..e97d5db6e40efb73926fe0e506d42b1fa14c15b6 100644 (file)
@@ -5,4 +5,9 @@
 uint32_t kds_s2000w_pixel_converter_pixel_to_tenth_of_inch(uint32_t dpi, uint32_t pixel)
 {
        return pixel * TENTH / dpi;
+}
+
+uint32_t kds_s2000w_pixel_converter_tenth_of_inch_to_pixel(uint32_t dpi, uint32_t tenth_inch)
+{
+       return tenth_inch * dpi / TENTH;
 }
\ No newline at end of file
index 33e6c04fcb843de1387bb2d18764f56c083e2bc6..374f8e3f9594f834344b2eafec8de55cf21cf9de 100644 (file)
@@ -3,5 +3,6 @@
 #include <stdint.h>
 
 uint32_t kds_s2000w_pixel_converter_pixel_to_tenth_of_inch(uint32_t dpi, uint32_t pixel);
+uint32_t kds_s2000w_pixel_converter_tenth_of_inch_to_pixel(uint32_t dpi, uint32_t tenth_inch);
 
 #endif
\ No newline at end of file
index 54adc4f9f6d26554926ce3ff02c33a3029d217a7..43afee402abb32f9e0b621a11e6768b38fdc46d3 100644 (file)
@@ -15,10 +15,21 @@ void kds_s2000w_max_tl_x_pixel_to_tenth_inch_test()
        assert_int_equal(tenth_inch, 75);
 }
 
+void kds_s2000w_max_tl_x_tenth_of_inch_to_pixel_test()
+{
+       uint32_t dpi = 300;
+       uint32_t tenth_inch = 75;
+
+       uint32_t pixel = kds_s2000w_pixel_converter_tenth_of_inch_to_pixel(dpi, tenth_inch);
+
+       assert_int_equal(pixel, 2250);
+}
+
 int main()
 {
        const struct CMUnitTest tests[] = {
-               cmocka_unit_test(kds_s2000w_max_tl_x_pixel_to_tenth_inch_test)
+               cmocka_unit_test(kds_s2000w_max_tl_x_pixel_to_tenth_inch_test),
+               cmocka_unit_test(kds_s2000w_max_tl_x_tenth_of_inch_to_pixel_test)
        };
 
        return cmocka_run_group_tests(tests, NULL, NULL);