Mercurial > hg > dmlib
diff tools/gfxconv.c @ 2100:81fb21dd3265
Add dmGetNPlanesFromNColors() and use it.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Tue, 05 Mar 2019 15:09:18 +0200 |
parents | dac89484f143 |
children | 78a9140f02b1 |
line wrap: on
line diff
--- a/tools/gfxconv.c Tue Mar 05 14:51:02 2019 +0200 +++ b/tools/gfxconv.c Tue Mar 05 15:09:18 2019 +0200 @@ -1424,21 +1424,13 @@ // Determine number of planes, if paletted if (spec->format == DM_COLFMT_PALETTE && - spec->nplanes == 0) - { - for (int n = 8; n >= 0;) - { - if ((image->pal->ncolors - 1) & (1 << n)) - { - spec->nplanes = n + 1; - break; - } - else - n--; - } - } + spec->nplanes == 0 && image->pal != NULL) + spec->nplanes = dmGetNPlanesFromNColors(image->pal->ncolors); + else + if (image->format == DM_COLFMT_GRAYSCALE) + spec->nplanes = 8; - if (spec->nplanes == 0) + if (spec->nplanes <= 0) spec->nplanes = 4; spec->fmtid = fmt->fmtid;