# HG changeset patch # User Matti Hamalainen # Date 1559498886 -10800 # Node ID 693c3e73eb342dd5b094fd4a4590076e010efe6c # Parent 894781b7310a8e71b97efc841351a2da97c50615 Fix palette remapping. diff -r 894781b7310a -r 693c3e73eb34 tools/gfxconv.c --- 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");