Mercurial > hg > dmlib
comparison tools/gfxconv.c @ 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 | 5ecd51009072 |
comparison
equal
deleted
inserted
replaced
2021:c8c698bb99b6 | 2022:eb6dafdd36dc |
---|---|
35 | 35 |
36 FFMT_LAST | 36 FFMT_LAST |
37 }; | 37 }; |
38 | 38 |
39 | 39 |
40 enum | |
41 { | |
42 FCMP_NONE = 0, | |
43 FCMP_BEST = 9 | |
44 }; | |
45 | |
46 | |
40 static const char *formatTypeList[FFMT_LAST] = | 47 static const char *formatTypeList[FFMT_LAST] = |
41 { | 48 { |
42 "AUTO", | 49 "AUTO", |
43 "ASCII text", | 50 "ASCII text", |
44 "ANSI text", | 51 "ANSI text", |
124 .nplanes = 4, | 131 .nplanes = 4, |
125 .bpp = 8, | 132 .bpp = 8, |
126 .planar = FALSE, | 133 .planar = FALSE, |
127 .paletted = FALSE, | 134 .paletted = FALSE, |
128 .format = 0, | 135 .format = 0, |
136 .compression = FCMP_BEST, | |
129 }; | 137 }; |
130 | 138 |
131 static const DMOptArg optList[] = | 139 static const DMOptArg optList[] = |
132 { | 140 { |
133 { 0, '?', "help", "Show this help", OPT_NONE }, | 141 { 0, '?', "help", "Show this help", OPT_NONE }, |
146 "width by X*n and height Y*n.", OPT_ARGREQ }, | 154 "width by X*n and height Y*n.", OPT_ARGREQ }, |
147 { 12, 'P', "paletted", "Use indexed/paletted output IF possible.", OPT_NONE }, | 155 { 12, 'P', "paletted", "Use indexed/paletted output IF possible.", OPT_NONE }, |
148 { 13, 'N', "nplanes", "# of bitplanes (some output formats)", OPT_ARGREQ }, | 156 { 13, 'N', "nplanes", "# of bitplanes (some output formats)", OPT_ARGREQ }, |
149 { 18, 'B', "bpp", "Bits per pixel (some output formats)", OPT_ARGREQ }, | 157 { 18, 'B', "bpp", "Bits per pixel (some output formats)", OPT_ARGREQ }, |
150 { 14, 'I', "interleave", "Interleaved/planar output (some output formats)", OPT_NONE }, | 158 { 14, 'I', "interleave", "Interleaved/planar output (some output formats)", OPT_NONE }, |
159 { 20, 'C', "compress", "Use compression -C <level 0-9>, 0 = disable, default is 9", OPT_ARGREQ }, | |
151 { 16, 'R', "remap", "Remap output image colors (-R <(#RRGGBB|index):index>[,<..>][+remove] | -R @map.txt[+remove])", OPT_ARGREQ }, | 160 { 16, 'R', "remap", "Remap output image colors (-R <(#RRGGBB|index):index>[,<..>][+remove] | -R @map.txt[+remove])", OPT_ARGREQ }, |
152 }; | 161 }; |
153 | 162 |
154 static const int optListN = sizeof(optList) / sizeof(optList[0]); | 163 static const int optListN = sizeof(optList) / sizeof(optList[0]); |
155 | 164 |
872 return FALSE; | 881 return FALSE; |
873 } | 882 } |
874 } | 883 } |
875 break; | 884 break; |
876 | 885 |
886 case 20: | |
887 if (!dmGetIntVal(optArg, &tmpUInt, NULL) || | |
888 tmpUInt > FCMP_BEST) | |
889 { | |
890 dmErrorMsg("Invalid compression setting '%s' [%d .. %d]\n", | |
891 optArg, FCMP_NONE, FCMP_BEST); | |
892 return FALSE; | |
893 } | |
894 optSpec.compression = tmpUInt; | |
895 break; | |
896 | |
877 default: | 897 default: |
878 dmErrorMsg("Unknown option '%s'.\n", currArg); | 898 dmErrorMsg("Unknown option '%s'.\n", currArg); |
879 return FALSE; | 899 return FALSE; |
880 } | 900 } |
881 | 901 |
1375 dmFree(hdrFilename); | 1395 dmFree(hdrFilename); |
1376 } | 1396 } |
1377 break; | 1397 break; |
1378 | 1398 |
1379 case DM_IMGFMT_IFF: | 1399 case DM_IMGFMT_IFF: |
1380 spec->compression = 1; | |
1381 spec->nplanes = 0; | 1400 spec->nplanes = 0; |
1382 for (int n = 8; n >= 0;) | 1401 for (int n = 8; n >= 0;) |
1383 { | 1402 { |
1384 if ((image->ncolors - 1) & (1 << n)) | 1403 if ((image->ncolors - 1) & (1 << n)) |
1385 { | 1404 { |