about summary refs log tree commit diff
path: root/converter/other/pgmtoppm.c
diff options
context:
space:
mode:
Diffstat (limited to 'converter/other/pgmtoppm.c')
-rw-r--r--converter/other/pgmtoppm.c25
1 files changed, 16 insertions, 9 deletions
diff --git a/converter/other/pgmtoppm.c b/converter/other/pgmtoppm.c
index c3a26594..62a388c2 100644
--- a/converter/other/pgmtoppm.c
+++ b/converter/other/pgmtoppm.c
@@ -37,7 +37,7 @@ parseCommandLine(int argc, char ** argv,
                  struct cmdlineInfo * const cmdlineP) {
 /*----------------------------------------------------------------------------
    parse program command line described in Unix standard form by argc
-   and argv.  Return the information in the options as *cmdlineP.  
+   and argv.  Return the information in the options as *cmdlineP.
 
    If command line is internally inconsistent (invalid options, etc.),
    issue error message to stderr and abort program.
@@ -82,9 +82,13 @@ parseCommandLine(int argc, char ** argv,
         }
     } else {
         /* Arguments are color or color range and file name */
+        /* For defaults, we use "rgbi:..." instead of the simpler "black"
+           and "white" so that we don't have unnecessary dependency on a
+           color dictionary being available.
+        */
         if (argc-1 < 1) {
-            cmdlineP->colorBlack = "black";
-            cmdlineP->colorWhite = "white";
+            cmdlineP->colorBlack = "rgbi:0/0/0";
+            cmdlineP->colorWhite = "rgbi:1/1/1";
         } else {
             char * buffer = strdup(argv[1]);
             char * hyphenPos = strchr(buffer, '-');
@@ -93,7 +97,7 @@ parseCommandLine(int argc, char ** argv,
                 cmdlineP->colorBlack = buffer;
                 cmdlineP->colorWhite = hyphenPos+1;
             } else {
-                cmdlineP->colorBlack = "black";
+                cmdlineP->colorBlack = "rgbi:0/0/0";
                 cmdlineP->colorWhite = buffer;
             }
         }
@@ -101,7 +105,7 @@ parseCommandLine(int argc, char ** argv,
             cmdlineP->inputFilename = "-";
         else
             cmdlineP->inputFilename = argv[2];
-        
+
         if (argc-1 > 2)
             pm_error("Program takes at most 2 arguments:  "
                      "color name/range and input file name.  "
@@ -128,7 +132,7 @@ convertWithMap(FILE * const ifP,
     pixval mapmaxval;
     pixel ** mappixels;
     unsigned int mapmaxcolor;
-    
+
     mapFileP = pm_openr(mapFileName);
     mappixels = ppm_readppm(mapFileP, &mapcols, &maprows, &mapmaxval);
     pm_close(mapFileP);
@@ -138,7 +142,7 @@ convertWithMap(FILE * const ifP,
 
     for (row = 0; row < rows; ++row) {
         unsigned int col;
-            
+
         pgm_readpgmrow(ifP, grayrow, cols, maxval, format);
 
         for (col = 0; col < cols; ++col) {
@@ -176,7 +180,7 @@ convertLinear(FILE * const ifP,
 
     colorBlack = ppm_parsecolor(colorNameBlack, maxval);
     colorWhite = ppm_parsecolor(colorNameWhite, maxval);
- 
+
     red0 = PPM_GETR(colorBlack);
     grn0 = PPM_GETG(colorBlack);
     blu0 = PPM_GETB(colorBlack);
@@ -228,7 +232,7 @@ main(int    argc,
         convertWithMap(ifP, cols, rows, maxval, format, cmdline.map,
                        stdout, grayrow, pixelrow);
     else
-        convertLinear(ifP, cols, rows, maxval, format, 
+        convertLinear(ifP, cols, rows, maxval, format,
                       cmdline.colorBlack, cmdline.colorWhite, stdout,
                       grayrow, pixelrow);
 
@@ -241,3 +245,6 @@ main(int    argc,
     */
     return 0;
 }
+
+
+