]> gitweb.hhaalo.de Git - sane-kds-s2000w-net.git/commitdiff
change init constraints
authorBastian Dehn <hhaalo@arcor.de>
Sun, 10 Mar 2024 12:42:13 +0000 (13:42 +0100)
committerBastian Dehn <hhaalo@arcor.de>
Sun, 10 Mar 2024 12:42:13 +0000 (13:42 +0100)
src/kds_s2000w_option_descriptors.c

index 10ace4eff9544f629a85e0c58c962eb5f8bcd141..72210575d673ea711e098278ecdcc66caa36e654 100644 (file)
@@ -5,26 +5,26 @@
 
 SANE_Option_Descriptor** descriptor_array = NULL;
 
-SANE_Word* constraint_dpi = NULL;
+SANE_Word constraint_dpi[] = {2, 200, 300};
+SANE_Word constraint_depth[] = {2, 1, 8};
+SANE_Range constraint_binarization_contrast = {-50, 50, 1};
+SANE_Range constraint_background_smoothing_aggressivness = {-10, 10, 1};
+SANE_Range constraint_color_drop_out_aggressiveness_range = {-10, 10, 1};
+SANE_Range constraint_color_balance_aggressiveness = {-2, 2, 1};
+SANE_Range constraint_color_balance_red = {-50, 50, 1};
+SANE_Range constraint_color_balance_green = {-50, 50, 1};
+SANE_Range constraint_color_balance_blue = {-50, 50, 1};
+SANE_Range constraint_foreground_boldness_aggressiveness = {-10, 10, 1};
 SANE_String_Const* constraint_scanside = NULL;
 SANE_String_Const* constraint_colormode = NULL;
 SANE_String_Const* constraint_colordrop = NULL;
-SANE_Range* constraint_color_drop_out_aggressiveness_range = NULL;
 SANE_String_Const* constraint_color_auto_brightnessmode = NULL;
 SANE_String_Const* constraint_color_balance_mode = NULL;
-SANE_Range* constraint_color_balance_aggressiveness = NULL;
-SANE_Range* constraint_color_balance_red = NULL;
-SANE_Range* constraint_color_balance_green = NULL;
-SANE_Range* constraint_color_balance_blue = NULL;
 SANE_String_Const* constraint_foreground_boldness_mode = NULL;
-SANE_Range* constraint_foreground_boldness_aggressiveness = NULL;
 SANE_String_Const* constraint_background_smoothing_mode = NULL;
-SANE_Range* constraint_background_smoothing_aggressivness = NULL;
 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_Option_Descriptor* _kds_s2000w_option_descriptor_standard_group()
 {
@@ -88,10 +88,6 @@ SANE_Option_Descriptor* _kds_s2000w_option_descriptor_dpi()
        descriptor->unit = SANE_UNIT_DPI;
        descriptor->cap = SANE_CAP_SOFT_DETECT | SANE_CAP_SOFT_SELECT;
        descriptor->constraint_type = SANE_CONSTRAINT_WORD_LIST;
-       constraint_dpi = malloc(sizeof(SANE_Int) * 3);
-       constraint_dpi[0] = 2;
-       constraint_dpi[1] = 200;
-       constraint_dpi[2] = 300;
        descriptor->constraint.word_list = constraint_dpi;
        descriptor->type = SANE_TYPE_INT;
        descriptor->size = sizeof(SANE_Int);
@@ -199,11 +195,7 @@ SANE_Option_Descriptor* _kds_s2000w_option_descriptor_color_drop_out_aggressiven
        descriptor->desc = "colordropoutaggressiveness";
        descriptor->cap = SANE_CAP_SOFT_DETECT | SANE_CAP_SOFT_SELECT;
        descriptor->constraint_type = SANE_CONSTRAINT_RANGE;
-       constraint_color_drop_out_aggressiveness_range = malloc(sizeof(SANE_Range));
-       constraint_color_drop_out_aggressiveness_range->min = -10;
-       constraint_color_drop_out_aggressiveness_range->max = 10;
-       constraint_color_drop_out_aggressiveness_range->quant = 1;
-       descriptor->constraint.range = constraint_color_drop_out_aggressiveness_range;
+       descriptor->constraint.range = &constraint_color_drop_out_aggressiveness_range;
        descriptor->type = SANE_TYPE_INT;
        descriptor->unit = SANE_UNIT_NONE;
        descriptor->size = sizeof(SANE_Int);
@@ -267,11 +259,7 @@ SANE_Option_Descriptor* _kds_s2000w_option_descriptor_color_balancea_agressivene
        descriptor->desc = "colorbalanceaggressiveness";
        descriptor->cap = SANE_CAP_SOFT_DETECT | SANE_CAP_SOFT_SELECT;
        descriptor->constraint_type = SANE_CONSTRAINT_RANGE;
-       constraint_color_balance_aggressiveness = malloc(sizeof(SANE_Range));
-       constraint_color_balance_aggressiveness->min = -2;
-       constraint_color_balance_aggressiveness->max = 2;
-       constraint_color_balance_aggressiveness->quant = 1;
-       descriptor->constraint.range = constraint_color_balance_aggressiveness;
+       descriptor->constraint.range = &constraint_color_balance_aggressiveness;
        descriptor->type = SANE_TYPE_INT;
        descriptor->unit = SANE_UNIT_NONE;
        descriptor->size = sizeof(SANE_Int);
@@ -289,11 +277,7 @@ SANE_Option_Descriptor* _kds_s2000w_option_descriptor_color_balance_red()
        descriptor->desc = "colorbalancered";
        descriptor->cap = SANE_CAP_SOFT_DETECT | SANE_CAP_SOFT_SELECT;
        descriptor->constraint_type = SANE_CONSTRAINT_RANGE;
-       constraint_color_balance_red = malloc(sizeof(SANE_Range));
-       constraint_color_balance_red->min = -50;
-       constraint_color_balance_red->max = 50;
-       constraint_color_balance_red->quant = 1;
-       descriptor->constraint.range = constraint_color_balance_red;
+       descriptor->constraint.range = &constraint_color_balance_red;
        descriptor->type = SANE_TYPE_INT;
        descriptor->unit = SANE_UNIT_NONE;
        descriptor->size = sizeof(SANE_Int);
@@ -311,11 +295,7 @@ SANE_Option_Descriptor* _kds_s2000w_option_descriptor_color_balance_green()
        descriptor->desc = "colorbalancegreen";
        descriptor->cap = SANE_CAP_SOFT_DETECT | SANE_CAP_SOFT_SELECT;
        descriptor->constraint_type = SANE_CONSTRAINT_RANGE;
-       constraint_color_balance_green = malloc(sizeof(SANE_Range));
-       constraint_color_balance_green->min = -50;
-       constraint_color_balance_green->max = 50;
-       constraint_color_balance_green->quant = 1;
-       descriptor->constraint.range = constraint_color_balance_green;
+       descriptor->constraint.range = &constraint_color_balance_green;
        descriptor->type = SANE_TYPE_INT;
        descriptor->unit = SANE_UNIT_NONE;
        descriptor->size = sizeof(SANE_Int);
@@ -333,11 +313,7 @@ SANE_Option_Descriptor* _kds_s2000w_option_descriptor_color_balance_blue()
        descriptor->desc = "colorbalanceblue";
        descriptor->cap = SANE_CAP_SOFT_DETECT | SANE_CAP_SOFT_SELECT;
        descriptor->constraint_type = SANE_CONSTRAINT_RANGE;
-       constraint_color_balance_blue = malloc(sizeof(SANE_Range));
-       constraint_color_balance_blue->min = -50;
-       constraint_color_balance_blue->max = 50;
-       constraint_color_balance_blue->quant = 1;
-       descriptor->constraint.range = constraint_color_balance_blue;
+       descriptor->constraint.range = &constraint_color_balance_blue;
        descriptor->type = SANE_TYPE_INT;
        descriptor->unit = SANE_UNIT_NONE;
        descriptor->size = sizeof(SANE_Int);
@@ -378,11 +354,7 @@ SANE_Option_Descriptor* _kds_s2000w_option_descriptor_foreground_boldness_aggres
        descriptor->desc = "Foreground Boldness Mode";
        descriptor->cap = SANE_CAP_SOFT_DETECT | SANE_CAP_SOFT_SELECT;
        descriptor->constraint_type = SANE_CONSTRAINT_RANGE;
-       constraint_foreground_boldness_aggressiveness = malloc(sizeof(SANE_Range));
-       constraint_foreground_boldness_aggressiveness->min = -10;
-       constraint_foreground_boldness_aggressiveness->max = 10;
-       constraint_foreground_boldness_aggressiveness->quant = 1;
-       descriptor->constraint.range = constraint_foreground_boldness_aggressiveness;
+       descriptor->constraint.range = &constraint_foreground_boldness_aggressiveness;
        descriptor->type = SANE_TYPE_INT;
        descriptor->unit = SANE_UNIT_NONE;
        descriptor->size = sizeof(SANE_Int);
@@ -423,11 +395,7 @@ SANE_Option_Descriptor* _kds_s2000w_option_descriptor_background_smoothing_aggre
        descriptor->desc = "Background Smoothing Aggressivenes";
        descriptor->cap = SANE_CAP_SOFT_DETECT | SANE_CAP_SOFT_SELECT;
        descriptor->constraint_type = SANE_CONSTRAINT_RANGE;
-       constraint_background_smoothing_aggressivness = malloc(sizeof(SANE_Range));
-       constraint_background_smoothing_aggressivness->min = -10;
-       constraint_background_smoothing_aggressivness->max = 10;
-       constraint_background_smoothing_aggressivness->quant = 1;
-       descriptor->constraint.range = constraint_background_smoothing_aggressivness;
+       descriptor->constraint.range = &constraint_background_smoothing_aggressivness;
        descriptor->type = SANE_TYPE_INT;
        descriptor->unit = SANE_UNIT_NONE;
        descriptor->size = sizeof(SANE_Int);
@@ -445,11 +413,7 @@ SANE_Option_Descriptor* _kds_s2000w_option_descriptor_binarization_contrast()
        descriptor->desc = SANE_DESC_CONTRAST;
        descriptor->cap = SANE_CAP_SOFT_DETECT | SANE_CAP_SOFT_SELECT;
        descriptor->constraint_type = SANE_CONSTRAINT_RANGE;
-       constraint_binarization_contrast = malloc(sizeof(SANE_Range));
-       constraint_binarization_contrast->min = -50;
-       constraint_binarization_contrast->max = 50;
-       constraint_binarization_contrast->quant = 1;
-       descriptor->constraint.range = constraint_binarization_contrast;
+       descriptor->constraint.range = &constraint_binarization_contrast;
        descriptor->type = SANE_TYPE_INT;
        descriptor->unit = SANE_UNIT_NONE;
        descriptor->size = sizeof(SANE_Int);
@@ -528,10 +492,6 @@ SANE_Option_Descriptor* _kds_s2000w_option_descriptor_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;
@@ -574,46 +534,26 @@ void kds_s2000w_option_descriptor_init_option_descriptors()
 void kds_s2000w_option_descriptor_free_option_descriptors()
 {
        debug_printf(ALL, "kds_s2000w_option_descriptor_free_option_descriptors");
-       free(constraint_dpi);
-       constraint_dpi = NULL;
        free(constraint_scanside);
        constraint_scanside = NULL;
        free(constraint_colormode);
        constraint_colormode = NULL;
        free(constraint_colordrop);
        constraint_colordrop = NULL;
-       free(constraint_color_drop_out_aggressiveness_range);
-       constraint_color_drop_out_aggressiveness_range = NULL;
        free(constraint_color_auto_brightnessmode);
        constraint_color_auto_brightnessmode = NULL;
        free(constraint_color_balance_mode);
        constraint_color_balance_mode = NULL;
-       free(constraint_color_balance_aggressiveness);
-       constraint_color_balance_aggressiveness = NULL;
-       free(constraint_color_balance_red);
-       constraint_color_balance_red = NULL;
-       free(constraint_color_balance_green);
-       constraint_color_balance_green = NULL;
-       free(constraint_color_balance_blue);
-       constraint_color_balance_blue = NULL;
        free(constraint_foreground_boldness_mode);
        constraint_foreground_boldness_mode = NULL;
-       free(constraint_foreground_boldness_aggressiveness);
-       constraint_foreground_boldness_aggressiveness = NULL;
        free(constraint_background_smoothing_mode);
        constraint_background_smoothing_mode = NULL;
-       free(constraint_background_smoothing_aggressivness);
-       constraint_background_smoothing_aggressivness = NULL;
        free(constraint_binarization_mode);
        constraint_binarization_mode = NULL;
-       free(constraint_binarization_contrast);
-       constraint_binarization_contrast = NULL;
        free(constraint_max_document_length);
        constraint_max_document_length = NULL;
        free(constraint_scan_source);
        constraint_scan_source = NULL;
-       free(constraint_depth);
-       constraint_depth = NULL;
 
        for (int i = 0; i < MAX_OPTION_COUNT; i++) {
                free(descriptor_array[i]);