Mercurial > hg > dmlib
changeset 2022:eb6dafdd36dc
Add option -C for controlling output file compression (PNG and IFF for now) in gfxconv.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Thu, 25 Oct 2018 19:07:00 +0300 |
parents | c8c698bb99b6 |
children | 362fb8295f0c |
files | tools/gfxconv.c tools/libgfx.c |
diffstat | 2 files changed, 22 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/tools/gfxconv.c Thu Oct 25 18:55:38 2018 +0300 +++ b/tools/gfxconv.c Thu Oct 25 19:07:00 2018 +0300 @@ -37,6 +37,13 @@ }; +enum +{ + FCMP_NONE = 0, + FCMP_BEST = 9 +}; + + static const char *formatTypeList[FFMT_LAST] = { "AUTO", @@ -126,6 +133,7 @@ .planar = FALSE, .paletted = FALSE, .format = 0, + .compression = FCMP_BEST, }; static const DMOptArg optList[] = @@ -148,6 +156,7 @@ { 13, 'N', "nplanes", "# of bitplanes (some output formats)", OPT_ARGREQ }, { 18, 'B', "bpp", "Bits per pixel (some output formats)", OPT_ARGREQ }, { 14, 'I', "interleave", "Interleaved/planar output (some output formats)", OPT_NONE }, + { 20, 'C', "compress", "Use compression -C <level 0-9>, 0 = disable, default is 9", OPT_ARGREQ }, { 16, 'R', "remap", "Remap output image colors (-R <(#RRGGBB|index):index>[,<..>][+remove] | -R @map.txt[+remove])", OPT_ARGREQ }, }; @@ -874,6 +883,17 @@ } break; + case 20: + if (!dmGetIntVal(optArg, &tmpUInt, NULL) || + tmpUInt > FCMP_BEST) + { + dmErrorMsg("Invalid compression setting '%s' [%d .. %d]\n", + optArg, FCMP_NONE, FCMP_BEST); + return FALSE; + } + optSpec.compression = tmpUInt; + break; + default: dmErrorMsg("Unknown option '%s'.\n", currArg); return FALSE; @@ -1377,7 +1397,6 @@ break; case DM_IMGFMT_IFF: - spec->compression = 1; spec->nplanes = 0; for (int n = 8; n >= 0;) {