# HG changeset patch # User Matti Hamalainen # Date 1405262695 -10800 # Node ID f2ac9877263eed5194e6428cc564319e344c1586 # Parent 5333dd4a99e4e43acf0b6dc1d57cd148aa33699e Bitmap format specifying option changes. diff -r 5333dd4a99e4 -r f2ac9877263e tools/gfxconv.c --- a/tools/gfxconv.c Sun Jul 13 17:42:40 2014 +0300 +++ b/tools/gfxconv.c Sun Jul 13 17:44:55 2014 +0300 @@ -117,8 +117,9 @@ optOutSubFormat = IMGFMT_PNG, optItemCount = -1, optPlanedWidth = 1, - optForcedFormat = -1; -int optInSkip = 0; + optForcedFormat = -1, + optInSkip = 0; + BOOL optInMulticolor = FALSE, optSequential = FALSE, optRemapColors = FALSE, @@ -141,7 +142,7 @@ { 0, '?', "help", "Show this help", OPT_NONE }, { 15, 'v', "verbose", "Increase verbosity", OPT_NONE }, { 3, 'o', "output", "Output filename", OPT_ARGREQ }, - { 1, 'i', "informat", "Set input format ([s]prite, [c]har, [b]itmap, [i]mage)", OPT_ARGREQ }, + { 1, 'i', "informat", "Set input format (sprite[:mc:sc], char[:mc|sc], bitmap[:], image)", OPT_ARGREQ }, { 2, 'm', "multicolor", "Input is multicolor / output in multicolor", OPT_NONE }, { 4, 's', "skip", "Skip bytes in input", OPT_ARGREQ }, { 5, 'f', "format", "Output format (see --formats)", OPT_ARGREQ }, @@ -150,7 +151,6 @@ { 6, 'c', "colormap", "Color mappings (see below for information)", OPT_ARGREQ }, { 7, 'n', "numitems", "How many 'items' to view (default: all)", OPT_ARGREQ }, { 9, 'S', "scale", "Scale output by x (image output only)", OPT_ARGREQ }, - { 10, 'b', "bformat", "Force input bitmap format (see below)", OPT_ARGREQ }, { 11, 'w', "width", "Item width (number of items per row, min 1)", OPT_ARGREQ }, { 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 }, @@ -185,7 +185,7 @@ "\n" "(Not all input->output combinations are actually supported.)\n" "\n" - "Available bitmap formats:\n" + "Available bitmap formats (-f bitmap:):\n" " Ext | Type | Description\n" "------+-----------------+-------------------------------------\n" ); @@ -519,6 +519,38 @@ dmError("Invalid input format '%s'.\n", optArg); return FALSE; } + + char *tmp = strchr(optArg, ':'); + if (tmp != NULL) + { + tmp++; + switch (optInFormat) + { + case FFMT_SPRITE: + case FFMT_CHAR: + if (strcasecmp(tmp, "mc") == 0) + optInMulticolor = TRUE; + else + if (strcasecmp(tmp, "sc") == 0) + optInMulticolor = FALSE; + else + { + dmError("Invalid input subformat for sprite/char: '%s', should be 'mc' or 'sc'.\n", + tmp); + return FALSE; + } + break; + + case FFMT_BITMAP: + if (!dmGetC64FormatByExt(tmp, &optInFormat, &optInSubFormat)) + { + dmError("Invalid bitmap subformat '%s', see format list for valid bformats.\n", + tmp); + return FALSE; + } + break; + } + } } break;