# HG changeset patch # User Matti Hamalainen # Date 1540483620 -10800 # Node ID eb6dafdd36dc19e364e89daa1559a0d1d525a8a4 # Parent c8c698bb99b63f94d1a8288364d0a34658ec9dcf Add option -C for controlling output file compression (PNG and IFF for now) in gfxconv. diff -r c8c698bb99b6 -r eb6dafdd36dc tools/gfxconv.c --- 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 , 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;) { diff -r c8c698bb99b6 -r eb6dafdd36dc tools/libgfx.c --- a/tools/libgfx.c Thu Oct 25 18:55:38 2018 +0300 +++ b/tools/libgfx.c Thu Oct 25 19:07:00 2018 +0300 @@ -525,6 +525,8 @@ goto error; } + png_set_compression_level(png_ptr, spec->compression); + png_set_IHDR(png_ptr, info_ptr, img->width * spec->scaleX, img->height * spec->scaleY,