]> gitweb.hhaalo.de Git - sane-kds-s2000w-net.git/commitdiff
change handler has channels
authorBastian Dehn <hhaalo@arcor.de>
Sun, 25 Feb 2024 09:34:28 +0000 (10:34 +0100)
committerBastian Dehn <hhaalo@arcor.de>
Sun, 25 Feb 2024 09:51:04 +0000 (10:51 +0100)
src/kds_s2000w_handler.c
src/kds_s2000w_handler.h
src/kds_s2000w_handler_opts.c

index b3cb0e88a4bad467e1ec06238b846d5dfab2f628..830b7bbcef7103a77e067143e39afb418c6bdb6f 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;
-       int channels = 1;
+       h->current_metadata->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)
-               channels = 3;
+               h->current_metadata->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 = channels * floor((h->current_metadata->pixels_per_line + 7) / 8);
+               h->current_metadata->bytes_per_line = h->current_metadata->channels * floor((h->current_metadata->pixels_per_line + 7) / 8);
        else
-               h->current_metadata->bytes_per_line = channels * h->current_metadata->pixels_per_line * h->current_metadata->depth / 8;
+               h->current_metadata->bytes_per_line = h->current_metadata->channels * h->current_metadata->pixels_per_line * h->current_metadata->depth / 8;
 
        h->current_metadata->valid = 1;
        h->current_metadata->is_last = 0;
@@ -179,6 +179,7 @@ handler* init_handler()
        h->current_scan_status->downloaded_images = 0;
        h->current_scan_status->complete_scanned = 0;
        h->current_metadata->format = 1;
+       h->current_metadata->channels = 3;
        h->current_metadata->is_last = 0;
        h->current_metadata->size = 0;
        h->current_metadata->bytes_per_line = 0;
index 6070817d3496dae54c35e0f4da5ed965a5a678be..2c49d4bfe2d5c379e1f8a0663416e618041e6636 100644 (file)
@@ -13,6 +13,7 @@ enum {
 
 typedef struct {
        int format;
+       int channels;
        int is_last;
        int size;
        int bytes_per_line;
index 0d4754c81a28981da2327d818d7f471b0e2149d6..43d9e5a66b398a4f0157064d062e1187f7d345a7 100644 (file)
@@ -258,6 +258,17 @@ void kds_s2000w_handler_set_option(handler* h, int option, void* value, int* inf
                        if (_change_output_type_to_images())
                                *info = RELOAD_OPTIONS;
 
+                       char* str_Value = (char*) value;
+                       if (strcmp(str_Value, "Color") == 0) {
+                               h->current_metadata->format = 1;
+                               h->current_metadata->channels = 3;
+                       } else {
+                               h->current_metadata->format = 0;
+                               h->current_metadata->channels = 1;
+                       }
+
+                       *info |= RELOAD_PARAMS;
+
                        break;
                case 5:
                        value_object = json_object_object_get(config, "SkipBlankPages");
@@ -380,7 +391,7 @@ void kds_s2000w_handler_set_option(handler* h, int option, void* value, int* inf
                case 25:
                        int* int_value = (int*) value;
                        h->current_metadata->depth = *int_value;
-                       *info = RELOAD_OPTIONS;
+                       *info = RELOAD_PARAMS;
                        break;
                default:
                        break;