Mercurial > hg > dmlib
changeset 2143:693c3e73eb34
Fix palette remapping.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Sun, 02 Jun 2019 21:08:06 +0300 |
parents | 894781b7310a |
children | 0bb1d0ad178f |
files | tools/gfxconv.c |
diffstat | 1 files changed, 4 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/tools/gfxconv.c Sun Jun 02 20:12:05 2019 +0300 +++ b/tools/gfxconv.c Sun Jun 02 21:08:06 2019 +0300 @@ -1055,14 +1055,14 @@ int dmRemapImageColors(DMImage **pdst, const DMImage *src) { - DMPalette *npal = NULL; + DMPalette *tmpPal = NULL; int *mapping = dmMalloc(src->pal->ncolors * sizeof(int)); BOOL *mapped = dmMalloc(src->pal->ncolors * sizeof(BOOL)); BOOL *used = dmMalloc(src->pal->ncolors * sizeof(BOOL)); int n, index, xc, yc, ncolors, res = DMERR_OK; DMImage *dst; - if ((res = dmPaletteAlloc(&npal, src->pal->ncolors, -1)) != DMERR_OK) + if ((res = dmPaletteAlloc(&tmpPal, src->pal->ncolors, -1)) != DMERR_OK) { dmErrorMsg("Could not allocate memory for remap palette.\n"); goto error; @@ -1178,7 +1178,7 @@ { if (mapping[index] >= 0) { - memcpy(&npal[mapping[index]], &(src->pal[index]), sizeof(DMColor)); + memcpy(&tmpPal->colors[mapping[index]], &(src->pal->colors[index]), sizeof(DMColor)); } } @@ -1201,7 +1201,7 @@ } // Set new palette, free memory - if ((res = dmPaletteCopy(&dst->pal, npal)) != DMERR_OK) + if ((res = dmPaletteCopy(&dst->pal, tmpPal)) != DMERR_OK) { res = dmError(DMERR_MALLOC, "Could not allocate memory for final remapped palette.\n");