char *progname = NULL;
char *version = "1.0";
+char block[3] = { ' ', 0, 0 };
int colormap = 1;
float gf[3] = { 1.0f, 1.0f, 1.0f };
int mode = 0;
int usage (int ret)
{
FILE *fd = ret ? stderr : stdout;
- fprintf (fd, "usage: %s [-c int] [-g gamma] [-h] [-t|-w] [-v int] <file>\n", progname);
+ fprintf (fd, "usage: %s [-b char] [-c int] [-g gamma] [-h] [-t|-w] [-v int] <file>\n", progname);
+ fprintf (fd, " -b: block caracter (%c)\n", block[0]);
fprintf (fd, " -c: color map [0..4] (%d)\n", colormap);
fprintf (fd, " -g: gamma correction (%.1f:%.1f:%.1f)\n", gf[0], gf[1], gf[2]);
fprintf (fd, " -h: help message\n");
}
char c = arg[1];
switch (c) {
+ case 'b':
+ arg = (arg[2]) ? arg + 2 : (--argc > 0) ? *(++argv) : NULL;
+ if (arg == NULL) {
+ VERBOSE (ERROR, fprintf (stderr, "%s: missing character block\n", progname));
+ return usage (1);
+ }
+ block[0] = arg[0];
+ break;
case 'c':
arg = (arg[2]) ? arg + 2 : (--argc > 0) ? *(++argv) : NULL;
if (arg == NULL) {
return 1;
}
+ /* configure block */
+ if (mode == 1) {
+ block[1] = block[0];
+ }
+
/* main process */
image_t *image = readpnm (filename);
if (!image) {
switch (colormap) {
case 0:
case 1:
- cprint (color, (mode == 0) ? " " : " ");
+ cprint (color, block);
break;
case 2:
- cprint8 (color, (mode == 0) ? " " : " ");
+ cprint8 (color, block);
break;
case 3:
- cprint24 (color, (mode == 0) ? " " : " ");
+ cprint24 (color, block);
}
}
printf ("\n");
}
/* test: display.exe 2>&1 | grep 'no file specified' */
+/* test: display.exe -b 2>&1 | grep missing */
/* test: display.exe -c 2>&1 | grep missing */
/* test: display.exe -c -1 2>&1 | grep 'incorrect colormap' */
/* test: display.exe -c 4 2>&1 | grep 'incorrect colormap' */
/* test: display.exe image/laurent4.ppm -c 3 */
/* test: display.exe image/debian.ppm -v 3 */
/* test: display.exe image/debian.ppm -g 4 */
+/* test: display.exe image/python3.ppm -b x */
/* test: display.exe image/python3.ppm -t */
/* test: display.exe image/python3.ppm -w */