Mercurial > hg > dmlib
comparison tools/gfxconv.c @ 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 |
comparison
equal
deleted
inserted
replaced
820:e3fa646aef0d | 821:8ec16cca0eef |
---|---|
152 { 10, 'b', "bformat", "Force input bitmap format (see below)", OPT_ARGREQ }, | 152 { 10, 'b', "bformat", "Force input bitmap format (see below)", OPT_ARGREQ }, |
153 { 11, 'w', "width", "Item width (number of items per row, min 1)", OPT_ARGREQ }, | 153 { 11, 'w', "width", "Item width (number of items per row, min 1)", OPT_ARGREQ }, |
154 { 12, 'P', "paletted", "Use indexed/paletted output (png, pcx output only)", OPT_NONE }, | 154 { 12, 'P', "paletted", "Use indexed/paletted output (png, pcx output only)", OPT_NONE }, |
155 { 13, 'B', "bplanes", "Bits per pixel OR # of bitplanes (certain output formats)", OPT_ARGREQ }, | 155 { 13, 'B', "bplanes", "Bits per pixel OR # of bitplanes (certain output formats)", OPT_ARGREQ }, |
156 { 14, 'I', "interleave", "Interleave scanlines (default: output whole planes)", OPT_NONE }, | 156 { 14, 'I', "interleave", "Interleave scanlines (default: output whole planes)", OPT_NONE }, |
157 { 16, 'R', "remap", "Remap output image colors (-R <(#RRGGBB|index):index>[,<..>] | -R @map.txt)", OPT_ARGREQ }, | 157 { 16, 'R', "remap", "Remap output image colors (-R <(#RRGGBB|index):index>[,<..>][+remove] | -R @map.txt[+remove])", OPT_ARGREQ }, |
158 { 18, 'r', "remap-remove", "Remove unused colors from remapped palette (requires -R)", OPT_NONE }, | |
159 }; | 158 }; |
160 | 159 |
161 static const int optListN = sizeof(optList) / sizeof(optList[0]); | 160 static const int optListN = sizeof(optList) / sizeof(optList[0]); |
162 | 161 |
163 | 162 |
217 "-R #000000:0,#ffffff:1 would remap black and white to indices 0 and 1.\n" | 216 "-R #000000:0,#ffffff:1 would remap black and white to indices 0 and 1.\n" |
218 "\n" | 217 "\n" |
219 "Remap file is specified as -R @filename, and it is a plan text file with\n" | 218 "Remap file is specified as -R @filename, and it is a plan text file with\n" |
220 "one remap definition per line. All empty lines and lines starting with a\n" | 219 "one remap definition per line. All empty lines and lines starting with a\n" |
221 "semicolor (;) will be ignored. Whitespace separating items is ignored, too.\n" | 220 "semicolor (;) will be ignored. Whitespace separating items is ignored, too.\n" |
221 "\n" | |
222 "Optional +remove can be specified (-R <...>+remove), which will remove all\n" | |
223 "unused colors from the palette. This is not usually desirable, for example\n" | |
224 "when converting multiple images to same palette.\n" | |
222 "\n" | 225 "\n" |
223 "Color map defs\n" | 226 "Color map defs\n" |
224 "--------------\n" | 227 "--------------\n" |
225 "Color map definitions are used for ANSI and image output, to declare what\n" | 228 "Color map definitions are used for ANSI and image output, to declare what\n" |
226 "output colors of the C64 palette are used for each single color/multi color\n" | 229 "output colors of the C64 palette are used for each single color/multi color\n" |
621 optSpec.interleave = TRUE; | 624 optSpec.interleave = TRUE; |
622 break; | 625 break; |
623 | 626 |
624 | 627 |
625 case 16: | 628 case 16: |
626 if (optArg[0] == '@') | 629 { |
627 { | 630 char *tmp; |
628 if (optArg[1] != 0) | 631 if ((tmp = dm_strrcasecmp(optArg, "+remove")) != NULL) |
629 { | 632 { |
630 int res; | 633 optRemapRemove = TRUE; |
631 if ((res = dmParseColorRemapFile(optArg + 1, | 634 *tmp = 0; |
632 optRemapTable, &optNRemapTable, DM_MAX_COLORS)) != DMERR_OK) | 635 } |
636 | |
637 if (optArg[0] == '@') | |
638 { | |
639 if (optArg[1] != 0) | |
640 { | |
641 int res; | |
642 if ((res = dmParseColorRemapFile(optArg + 1, | |
643 optRemapTable, &optNRemapTable, DM_MAX_COLORS)) != DMERR_OK) | |
644 return FALSE; | |
645 } | |
646 else | |
647 { | |
648 dmError("No remap filename given.\n"); | |
633 return FALSE; | 649 return FALSE; |
634 } | 650 } |
635 else | 651 else |
636 { | 652 { |
637 dmError("No remap filename given.\n"); | 653 if (!dmParseMapOptionString(optArg, optRemapTable, |
638 return FALSE; | 654 &optNRemapTable, DM_MAX_COLORS, TRUE, "color remap option")) |
655 return FALSE; | |
639 } | 656 } |
640 } | 657 } |
641 else | |
642 { | |
643 if (!dmParseMapOptionString(optArg, optRemapTable, | |
644 &optNRemapTable, DM_MAX_COLORS, TRUE, "color remap option")) | |
645 return FALSE; | |
646 } | |
647 | 658 |
648 optRemapColors = TRUE; | 659 optRemapColors = TRUE; |
649 break; | |
650 | |
651 case 18: | |
652 optRemapRemove = TRUE; | |
653 break; | 660 break; |
654 | 661 |
655 default: | 662 default: |
656 dmError("Unknown option '%s'.\n", currArg); | 663 dmError("Unknown option '%s'.\n", currArg); |
657 return FALSE; | 664 return FALSE; |