aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Jonas Gunz <himself@jonasgunz.de> 2020-05-12 00:06:05 +0200
committerGravatar Jonas Gunz <himself@jonasgunz.de> 2020-05-12 00:06:05 +0200
commit44cecf8d0b792c69cdfc398761d2ad27b05a122e (patch)
treeeda513408a9b406f7ab9e8d7ba68dc5571d90324
parent666e49989b88dac36d4e6a5b1e7ac695011b0b36 (diff)
downloadAsciiMap-44cecf8d0b792c69cdfc398761d2ad27b05a122e.tar.gz
Added dynamic range
-rw-r--r--src/main.c22
1 files changed, 15 insertions, 7 deletions
diff --git a/src/main.c b/src/main.c
index 62cfed2..1ca92e1 100644
--- a/src/main.c
+++ b/src/main.c
@@ -28,6 +28,7 @@ struct prog_param
uint8_t use_stdin;
uint8_t use_whitespace;
uint8_t fit_width;
+ uint8_t dynamic_range;
};
struct prog_param parse_args(int argc, char *argv[]);
@@ -133,10 +134,16 @@ int main(int argc, char *argv[])
}//for y
}//for x
- DEBUG_PRINTF("Brightness Values: Min: %u Max: %u\n", b_min, b_max);
if(args.color)
printf("\e[0m");//Default colors
+
+ if(! args.dynamic_range) {
+ b_min = 0;
+ b_max = 255;
+ } else {
+ DEBUG_PRINTF("Dynamic Range: Brightness Values: Min: %u Max: %u\n", b_min, b_max);
+ }
//Print buffer
for(int y = 0; y<size_y; y++) {
@@ -146,7 +153,7 @@ int main(int argc, char *argv[])
if(args.use_whitespace)
printf(" ");
else
- printf("%c", calc_char(ascii_buff[x][y], 0,255));//b_min, b_max));
+ printf("%c", calc_char(ascii_buff[x][y], b_min, b_max));
}
printf("\e[0m\n");
}
@@ -177,13 +184,10 @@ struct prog_param parse_args(int argc, char *argv[])
{
struct prog_param ret;
+ memset(&ret, 0, sizeof ret);
+
ret.filename = NULL;
ret.charsize_x = CHAR_SIZE_X;
- ret.charsize_y = 0;
- ret.color = 0;
- ret.use_stdin = 0;
- ret.use_whitespace = 0;
- ret.fit_width = 0;
for (int i = 1; i < argc; i++) {
if(argv[i][0] == '-') {
@@ -217,6 +221,9 @@ struct prog_param parse_args(int argc, char *argv[])
i++;
ret.fit_width = atoi(argv[i]);
break;
+ case 'd':
+ ret.dynamic_range = 1;
+ break;
default:
printf("Unrecognized Option '%c'\n", argv[icpy][o]);
print_help();
@@ -253,6 +260,7 @@ void print_help( void )
printf("Options:\n -h: Print this help message\n -x VAL: set the width of block wich makes up one character. Default: %i\n", CHAR_SIZE_X);
printf(" -y VAL: set the height of block wich makes up one character. Default: 2*x\n -c: Print in ANSI color mode. Default: OFF\n");
printf(" -i: Read from STDIN instead of file.\n -w: print only whitespaces with background color\n");
+ printf(" -d: Dynamic brightness range");
}