Mercurial > hg > dmlib
changeset 821:8ec16cca0eef
Change -R remap option syntax slightly and document it.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Fri, 16 May 2014 20:10:49 +0300 |
parents | e3fa646aef0d |
children | b034c1457aa5 |
files | tools/gfxconv.c |
diffstat | 1 files changed, 26 insertions(+), 19 deletions(-) [+] |
line wrap: on
line diff
--- a/tools/gfxconv.c Fri May 16 20:09:45 2014 +0300 +++ b/tools/gfxconv.c Fri May 16 20:10:49 2014 +0300 @@ -154,8 +154,7 @@ { 12, 'P', "paletted", "Use indexed/paletted output (png, pcx output only)", OPT_NONE }, { 13, 'B', "bplanes", "Bits per pixel OR # of bitplanes (certain output formats)", OPT_ARGREQ }, { 14, 'I', "interleave", "Interleave scanlines (default: output whole planes)", OPT_NONE }, - { 16, 'R', "remap", "Remap output image colors (-R <(#RRGGBB|index):index>[,<..>] | -R @map.txt)", OPT_ARGREQ }, - { 18, 'r', "remap-remove", "Remove unused colors from remapped palette (requires -R)", OPT_NONE }, + { 16, 'R', "remap", "Remap output image colors (-R <(#RRGGBB|index):index>[,<..>][+remove] | -R @map.txt[+remove])", OPT_ARGREQ }, }; static const int optListN = sizeof(optList) / sizeof(optList[0]); @@ -220,6 +219,10 @@ "one remap definition per line. All empty lines and lines starting with a\n" "semicolor (;) will be ignored. Whitespace separating items is ignored, too.\n" "\n" + "Optional +remove can be specified (-R <...>+remove), which will remove all\n" + "unused colors from the palette. This is not usually desirable, for example\n" + "when converting multiple images to same palette.\n" + "\n" "Color map defs\n" "--------------\n" "Color map definitions are used for ANSI and image output, to declare what\n" @@ -623,35 +626,39 @@ case 16: - if (optArg[0] == '@') { - if (optArg[1] != 0) + char *tmp; + if ((tmp = dm_strrcasecmp(optArg, "+remove")) != NULL) + { + optRemapRemove = TRUE; + *tmp = 0; + } + + if (optArg[0] == '@') { - int res; - if ((res = dmParseColorRemapFile(optArg + 1, - optRemapTable, &optNRemapTable, DM_MAX_COLORS)) != DMERR_OK) + if (optArg[1] != 0) + { + int res; + if ((res = dmParseColorRemapFile(optArg + 1, + optRemapTable, &optNRemapTable, DM_MAX_COLORS)) != DMERR_OK) + return FALSE; + } + else + { + dmError("No remap filename given.\n"); return FALSE; } else { - dmError("No remap filename given.\n"); - return FALSE; + if (!dmParseMapOptionString(optArg, optRemapTable, + &optNRemapTable, DM_MAX_COLORS, TRUE, "color remap option")) + return FALSE; } } - else - { - if (!dmParseMapOptionString(optArg, optRemapTable, - &optNRemapTable, DM_MAX_COLORS, TRUE, "color remap option")) - return FALSE; - } optRemapColors = TRUE; break; - case 18: - optRemapRemove = TRUE; - break; - default: dmError("Unknown option '%s'.\n", currArg); return FALSE;