From: Bastian Dehn Date: Sun, 25 Feb 2024 09:34:28 +0000 (+0100) Subject: change handler has channels X-Git-Tag: v1.0.0^2~193 X-Git-Url: https://gitweb.hhaalo.de/?a=commitdiff_plain;h=f8ca30c3633372d6afa1114b09823d8025d0a277;p=sane-kds-s2000w-net.git change handler has channels --- diff --git a/src/kds_s2000w_handler.c b/src/kds_s2000w_handler.c index b3cb0e8..830b7bb 100644 --- a/src/kds_s2000w_handler.c +++ b/src/kds_s2000w_handler.c @@ -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; diff --git a/src/kds_s2000w_handler.h b/src/kds_s2000w_handler.h index 6070817..2c49d4b 100644 --- a/src/kds_s2000w_handler.h +++ b/src/kds_s2000w_handler.h @@ -13,6 +13,7 @@ enum { typedef struct { int format; + int channels; int is_last; int size; int bytes_per_line; diff --git a/src/kds_s2000w_handler_opts.c b/src/kds_s2000w_handler_opts.c index 0d4754c..43d9e5a 100644 --- a/src/kds_s2000w_handler_opts.c +++ b/src/kds_s2000w_handler_opts.c @@ -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;