]> gitweb.hhaalo.de Git - sane-kds-s2000w-net.git/commitdiff
add bit depth option
authorBastian Dehn <hhaalo@arcor.de>
Sat, 24 Feb 2024 17:18:04 +0000 (18:18 +0100)
committerBastian Dehn <hhaalo@arcor.de>
Sat, 24 Feb 2024 17:18:04 +0000 (18:18 +0100)
src/kds_s2000w_handler_opts.c
src/kds_s2000w_option_descriptors.c
src/kds_s2000w_option_descriptors.h

index ab99046c0a25a46468134adc6816f5a900e8ae5c..72f002dc020cdc3b7723539eff4ea042f4516024 100644 (file)
@@ -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;
        }
index c516486fc2a2bff71175ce2b0eacc38954806255..68d68f28559dff81cedfefa886b6e7139e86c31e 100644 (file)
@@ -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);
index 11f8fe7184725eaac2d3ee7b6dc1558bc5c7437b..49a05c691f8487965df7f8f39046c9ba3bfa6d42 100644 (file)
@@ -2,7 +2,7 @@
 #define KDS_S2000W_OPTION_DESCRIPTORS_H
 #include <sane/sane.h>
 
-#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();