From bbe8e9e25b62d2ee2d8c478e9b1090cc4020b462 Mon Sep 17 00:00:00 2001 From: Bastian Dehn Date: Sat, 24 Feb 2024 18:18:04 +0100 Subject: [PATCH] add bit depth option --- src/kds_s2000w_handler_opts.c | 16 ++++++++++--- src/kds_s2000w_option_descriptors.c | 36 +++++++++++++++++++++++++---- src/kds_s2000w_option_descriptors.h | 2 +- 3 files changed, 45 insertions(+), 9 deletions(-) diff --git a/src/kds_s2000w_handler_opts.c b/src/kds_s2000w_handler_opts.c index ab99046..72f002d 100644 --- a/src/kds_s2000w_handler_opts.c +++ b/src/kds_s2000w_handler_opts.c @@ -222,15 +222,20 @@ void kds_s2000w_handler_get_option(handler* h, int option, void* value) _write_string_value(value_object, value); break; case 25: - memcpy(value, &gamma_table[0][0], sizeof(int) * 256); + int depth = h->current_metadata->depth; + int* int_value = (int*) value; + *int_value = depth; break; case 26: - memcpy(value, &gamma_table[0][1], sizeof(int) * 256); + memcpy(value, &gamma_table[0][0], sizeof(int) * 256); break; case 27: - memcpy(value, &gamma_table[0][2], sizeof(int) * 256); + memcpy(value, &gamma_table[0][1], sizeof(int) * 256); break; case 28: + memcpy(value, &gamma_table[0][2], sizeof(int) * 256); + break; + case 29: memcpy(value, &gamma_table[0][3], sizeof(int) * 256); default: break; @@ -378,6 +383,11 @@ void kds_s2000w_handler_set_option(handler* h, int option, void* value, int* inf _load_options(h); return; break; + case 25: + int* int_value = (int*) value; + h->current_metadata->depth = *int_value; + *info = RELOAD_OPTIONS; + break; default: break; } diff --git a/src/kds_s2000w_option_descriptors.c b/src/kds_s2000w_option_descriptors.c index c516486..68d68f2 100644 --- a/src/kds_s2000w_option_descriptors.c +++ b/src/kds_s2000w_option_descriptors.c @@ -25,6 +25,7 @@ SANE_String_Const* constraint_binarization_mode = NULL; SANE_Range* constraint_binarization_contrast = NULL; SANE_String_Const* constraint_max_document_length = NULL; SANE_String_Const* constraint_scan_source = NULL; +SANE_Word* constraint_depth = NULL; SANE_Range* constraint_gamma_range = NULL; SANE_Range* constraint_gamma_range_r = NULL; SANE_Range* constraint_gamma_range_g = NULL; @@ -534,7 +535,7 @@ SANE_Option_Descriptor* _kds_s2000w_option_descriptor_scan_source() descriptor->name = SANE_NAME_SCAN_SOURCE; descriptor->title = SANE_TITLE_SCAN_SOURCE; descriptor->desc = SANE_DESC_SCAN_SOURCE; - descriptor->cap = SANE_CAP_SOFT_DETECT | SANE_CAP_SOFT_SELECT;; + descriptor->cap = SANE_CAP_SOFT_DETECT | SANE_CAP_SOFT_SELECT; descriptor->constraint_type = SANE_CONSTRAINT_STRING_LIST; constraint_scan_source = malloc(sizeof(char*) * 4); constraint_scan_source[0] = "DocumentFeeder"; @@ -566,6 +567,28 @@ SANE_Option_Descriptor* _kds_s2000w_option_descriptor_config_reset() return descriptor; } +SANE_Option_Descriptor* _kds_s2000w_option_descriptor_depth() +{ + debug_printf(ALL, "kds_s2000w_option_descriptor_depth"); + SANE_Option_Descriptor* descriptor = malloc(sizeof(SANE_Option_Descriptor)); + + descriptor->name = SANE_NAME_BIT_DEPTH; + descriptor->title = SANE_TITLE_BIT_DEPTH; + descriptor->desc = SANE_DESC_BIT_DEPTH; + descriptor->cap = SANE_CAP_SOFT_DETECT | SANE_CAP_SOFT_SELECT; + descriptor->constraint_type = SANE_CONSTRAINT_WORD_LIST; + constraint_depth = malloc(sizeof(SANE_Int) * 3); + constraint_depth[0] = 2; + constraint_depth[1] = 1; + constraint_depth[2] = 8; + descriptor->constraint.word_list = constraint_depth; + descriptor->type = SANE_TYPE_INT; + descriptor->unit = SANE_UNIT_NONE; + descriptor->size = sizeof(SANE_Int); + + return descriptor; +} + SANE_Option_Descriptor* _kds_s2000w_option_descriptor_gamma_vector() { debug_printf(ALL, "kds_s2000w_option_descriptor_gamma_vector"); @@ -684,10 +707,11 @@ void kds_s2000w_option_descriptor_init_option_descriptors() descriptor_array[22] = _kds_s2000w_option_descriptor_max_document_length(); descriptor_array[23] = _kds_s2000w_option_descriptor_scan_source(); descriptor_array[24] = _kds_s2000w_option_descriptor_config_reset(); - descriptor_array[25] = _kds_s2000w_option_descriptor_gamma_vector(); - descriptor_array[26] = _kds_s2000w_option_descriptor_gamma_vector_r(); - descriptor_array[27] = _kds_s2000w_option_descriptor_gamma_vector_g(); - descriptor_array[28] = _kds_s2000w_option_descriptor_gamma_vector_b(); + descriptor_array[25] = _kds_s2000w_option_descriptor_depth(); + descriptor_array[26] = _kds_s2000w_option_descriptor_gamma_vector(); + descriptor_array[27] = _kds_s2000w_option_descriptor_gamma_vector_r(); + descriptor_array[28] = _kds_s2000w_option_descriptor_gamma_vector_g(); + descriptor_array[29] = _kds_s2000w_option_descriptor_gamma_vector_b(); } void kds_s2000w_option_descriptor_free_option_descriptors() @@ -733,6 +757,8 @@ void kds_s2000w_option_descriptor_free_option_descriptors() constraint_max_document_length = NULL; free(constraint_scan_source); constraint_scan_source = NULL; + free(constraint_depth); + constraint_depth = NULL; free(constraint_gamma_range); constraint_gamma_range = NULL; free(constraint_gamma_range_r); diff --git a/src/kds_s2000w_option_descriptors.h b/src/kds_s2000w_option_descriptors.h index 11f8fe7..49a05c6 100644 --- a/src/kds_s2000w_option_descriptors.h +++ b/src/kds_s2000w_option_descriptors.h @@ -2,7 +2,7 @@ #define KDS_S2000W_OPTION_DESCRIPTORS_H #include -#define MAX_OPTION_COUNT 29 +#define MAX_OPTION_COUNT 30 void kds_s2000w_option_descriptor_init_option_descriptors(); void kds_s2000w_option_descriptor_free_option_descriptors(); -- 2.39.5