#include "color.h"
-#define nbcolors 16
+#define nbcolors0 8
+#define nbcolors1 16
-color_t colors[nbcolors] = {
+color_t colors0[nbcolors0] = {
+ { 40, 0.0, 0.0, 0.0 },
+ { 41, 0.7, 0.1, 0.1 },
+ { 42, 0.1, 0.7, 0.1 },
+ { 43, 0.7, 0.4, 0.1 },
+ { 44, 0.1, 0.1, 0.7 },
+ { 45, 0.7, 0.1, 0.7 },
+ { 46, 0.1, 0.7, 0.7 },
+ { 47, 0.7, 0.7, 0.7 },
+};
+
+color_t colors1[nbcolors1] = {
{ 40, 0.0, 0.0, 0.0 },
{ 41, 0.7, 0.1, 0.1 },
{ 42, 0.1, 0.7, 0.1 },
{ 107, 1.0, 1.0, 1.0 },
};
-color_t *findcolor (float red, float green, float blue)
+color_t *findcolor (float red, float green, float blue, int colormap)
{
color_t *color = NULL;
int i;
float dist = 3;
+ int nbcolors;
+ color_t *colors;
+ switch (colormap) {
+ case 0:
+ nbcolors = nbcolors0;
+ colors = colors0;
+ break;
+ case 1:
+ default:
+ nbcolors = nbcolors1;
+ colors = colors1;
+ break;
+ }
for (i = 0; i < nbcolors; i++) {
float r = (colors + i)->red - red;
float g = (colors + i)->green - green;
char *progname = NULL;
char *version = "1.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 [-g gamma] [-h] [-t|-w] [-v int] <file>\n", progname);
+ fprintf (fd, "usage: %s [-c int] [-g gamma] [-h] [-t|-w] [-v int] <file>\n", progname);
+ fprintf (fd, " -c: color map [0..2] (%d)\n", colormap);
fprintf (fd, " -g: gamma correction (%.1f:%.1f:%.1f)\n", gf[0], gf[1], gf[2]);
fprintf (fd, " -h: help message\n");
fprintf (fd, " -t: thin mode (%s)\n", (mode == 0) ? "on" : "off");
}
char c = arg[1];
switch (c) {
+ case 'c':
+ arg = (arg[2]) ? arg + 2 : (--argc > 0) ? *(++argv) : NULL;
+ if (arg == NULL) {
+ VERBOSE (ERROR, fprintf (stderr, "%s: missing color map\n", progname));
+ return usage (1);
+ }
+ colormap = atoi (arg);
+ break;
case 'g':
arg = (arg[2]) ? arg + 2 : (--argc > 0) ? *(++argv) : NULL;
if (arg == NULL) {
for (l = 0; l < image->height; l++) {
for (k = 0; k < image->width; k++) {
int ind = k + image->width * l;
- color_t *color = findcolor (correction (image->red[ind], gf[0]), correction (image->green[ind], gf[1]), correction (image->blue[ind], gf[2]));
+ color_t *color = findcolor (correction (image->red[ind], gf[0]), correction (image->green[ind], gf[1]), correction (image->blue[ind], gf[2]), colormap);
cprint (color, (mode == 0) ? " " : " ");
}
printf ("\n");
}
/* test: display.exe 2>&1 | grep 'no file specified' */
+/* test: display.exe -c 2>&1 | grep missing */
/* test: display.exe -g 2>&1 | grep 'no gamma specified' */
/* test: display.exe -g -1.0 2>&1 | grep 'incorrect gamma' */
/* test: display.exe -g 1.1:0:1.1 2>&1 | grep 'incorrect gamma' */