]> gitweb.hhaalo.de Git - sane-kds-s2000w-net.git/commitdiff
Revert "add channels into handler"
authorBastian Dehn <hhaalo@arcor.de>
Sun, 25 Feb 2024 08:55:50 +0000 (09:55 +0100)
committerBastian Dehn <hhaalo@arcor.de>
Sun, 25 Feb 2024 08:55:50 +0000 (09:55 +0100)
This reverts commit 8c07354b6384039984b26077168516c9c915a882.

src/kds_s2000w_handler.c
src/kds_s2000w_handler.h
src/kds_s2000w_handler_opts.c
src/kds_s2000w_handler_opts.h
src/kds_s2000w_net.c
tests/kds_s2000w_net_get_params_tests.c

index 31b732fd81c90a4681d2cbbeb9f04f970a5fb7a5..b3cb0e88a4bad467e1ec06238b846d5dfab2f628 100644 (file)
@@ -32,7 +32,7 @@ void _get_current_metadata(handler* h)
        json_object* metadataResp = NULL;
        json_object* metadata = NULL;
        json_object* mdata_value = NULL;
-       h->current_metadata->channels = 1;
+       int channels = 1;
 
        metadataResp = json_tokener_parse(resp->data);
        metadata = json_object_object_get(metadataResp, "Metadata");
@@ -68,7 +68,7 @@ void _get_current_metadata(handler* h)
                h->current_metadata->format = 0;
 
        if (h->current_metadata->format == 1)
-               h->current_metadata->channels = 3;
+               channels = 3;
 
        if (pnm_image.size > 0) {
                free(pnm_image.data);
@@ -87,9 +87,9 @@ void _get_current_metadata(handler* h)
        debug_printf_int(DEBUG, "size of pnm image", pnm_image.size);
 
        if (h->current_metadata->depth == 1)
-               h->current_metadata->bytes_per_line = h->current_metadata->channels * floor((h->current_metadata->pixels_per_line + 7) / 8);
+               h->current_metadata->bytes_per_line = channels * floor((h->current_metadata->pixels_per_line + 7) / 8);
        else
-               h->current_metadata->bytes_per_line = h->current_metadata->channels * h->current_metadata->pixels_per_line * h->current_metadata->depth / 8;
+               h->current_metadata->bytes_per_line = channels * h->current_metadata->pixels_per_line * h->current_metadata->depth / 8;
 
        h->current_metadata->valid = 1;
        h->current_metadata->is_last = 0;
@@ -185,7 +185,6 @@ handler* init_handler()
        h->current_metadata->pixels_per_line = 0;
        h->current_metadata->lines = 0;
        h->current_metadata->depth = 8;
-       h->current_metadata->channels = 3;
        h->current_metadata->valid = 0;
        h->current_metadata->scanned_all_complete = 0;
        h->current_metadata->image = NULL;
index 48d22c888726c315a1fa5c37f3f0a129f0b3500e..b144adca849d78d330139304fa61b45d1b22c0c4 100644 (file)
@@ -8,7 +8,7 @@ enum {
 
 enum {
        RELOAD_OPTIONS = 2,
-       RELOAD_PARAMS = 4
+       REALOD_PARAMS = 4
 };
 
 typedef struct {
@@ -19,7 +19,6 @@ typedef struct {
        int pixels_per_line;
        int lines;
        int depth;
-       int channels;
        int valid;
        int scanned_all_complete;
        void* image;
@@ -52,7 +51,7 @@ handler* init_handler();
 void free_handler(handler* h);
 void kds_s2000w_handler_open(const char* devicename, void** handle);
 void kds_s2000w_handler_close(handler* h);
-void kds_s2000w_handler_get_option(handler* handle, int option, void* value, int* info);
+void kds_s2000w_handler_get_option(handler* handle, int option, void* value);
 void kds_s2000w_handler_set_option(handler* handle, int option, void* value, int* info);
 void kds_s2000w_handler_set_option_auto(int option);
 void kds_s2000w_handler_start_scan(handler* h);
index c0b14d919dd5688d85a05c2006ae99a08e2bf2f7..72f002dc020cdc3b7723539eff4ea042f4516024 100644 (file)
@@ -117,7 +117,7 @@ void init_gamma_table()
        }
 }
 
-void kds_s2000w_handler_get_option(handler* h, int option, void* value,  int* info)
+void kds_s2000w_handler_get_option(handler* h, int option, void* value)
 {
        config = json_object_object_get(resp_config, "Configuration");
        json_object* value_object = NULL;
@@ -139,13 +139,10 @@ void kds_s2000w_handler_get_option(handler* h, int option, void* value,  int* in
                        value_object = json_object_object_get(config, "ColorMode");
                        _write_string_value(value_object, value);
 
-                       if (strcmp(value, "Color") == 0) {
+                       if (strcmp(value, "Color") == 0)
                                h->current_metadata->format = 1;
-                               h->current_metadata->channels = 3;
-                       } else {
+                       else
                                h->current_metadata->format = 0;
-                               h->current_metadata->channels = 1;
-                       }
 
                        break;
                case 5:
index 0bdf7d6a3356e358db6336e81ddd19e9ffdea13b..2fdbfd8d795ddd5048aca92087380d4e3454670e 100644 (file)
@@ -1,7 +1,7 @@
 #ifndef KDS_S2000W_HANDLER_OPTS_H
 #define KDS_S2000W_HANDLER_OPTS_H
 void init_gamma_table();
-void kds_s2000w_handler_get_option(handler* h, int option, void* value, int* info);
+void kds_s2000w_handler_get_option(handler* h, int option, void* value);
 void kds_s2000w_handler_set_option(handler* h, int option, void* value, int* info);
 void kds_s2000w_handler_set_option_auto(int option);
 #endif
\ No newline at end of file
index a25e900d0784965e5838a14ecd851fb159898a4a..5972e9d24c187771cd21c12dd3207eb62f7abeac 100644 (file)
@@ -2,7 +2,6 @@
 #include <stdlib.h>
 #include <string.h>
 #include <unistd.h>
-#include <math.h>
 #include <sane/sane.h>
 #include "kds_s2000w_option_descriptors.h"
 #include "kds_s2000w_handler.h"
@@ -100,7 +99,7 @@ SANE_Status _sane_kds_s2000w_net_control_option(SANE_Handle handle,
        debug_printf(ALL, "sane_kds_s2000w_net_control_option");
        handler* h = (handler*) handle;
        if (action == SANE_ACTION_GET_VALUE)
-               kds_s2000w_handler_get_option(h, option, value, info);
+               kds_s2000w_handler_get_option(h, option, value);
 
        if (action == SANE_ACTION_SET_VALUE)
                kds_s2000w_handler_set_option(h, option, value, info);
index 29eb5bcaf00dfdac048761bc7de7a2e88ae180f3..5901a5ba0933ea58a94ebfe2341c91dd5713c4dc 100644 (file)
@@ -24,6 +24,7 @@ START_TEST(kds_s2000w_net_get_parameters_with_image_data)
        h->current_metadata->valid = 1;
        h->current_metadata->format = 1;
        h->current_metadata->is_last = 0;
+       h->current_metadata->bytes_per_line = 42;
        h->current_metadata->pixels_per_line = 1080;
        h->current_metadata->lines = 100;
        h->current_metadata->depth = 8;
@@ -33,7 +34,7 @@ START_TEST(kds_s2000w_net_get_parameters_with_image_data)
 
        ck_assert_int_eq(params.format, 1);
        ck_assert_int_eq(params.last_frame, 0);
-       ck_assert_int_eq(params.bytes_per_line, 0);
+       ck_assert_int_eq(params.bytes_per_line, 42);
        ck_assert_int_eq(params.pixels_per_line, 1080);
        ck_assert_int_eq(params.lines, 100);
        ck_assert_int_eq(params.depth, 8);