# HG changeset patch # User Matti Hamalainen # Date 1352250181 -7200 # Node ID 7c7a575902367d7366c518522ed9ccfa4765704f # Parent 0fd0e301b6fc9d34d43abf1168a113d6099371d1 Calculate number of remapped colors. diff -r 0fd0e301b6fc -r 7c7a57590236 gfxconv.c --- a/gfxconv.c Wed Nov 07 01:46:49 2012 +0200 +++ b/gfxconv.c Wed Nov 07 03:03:01 2012 +0200 @@ -747,7 +747,7 @@ DMColor *npal = dmCalloc(image->ncolors, sizeof(DMColor)); int *dpal = dmMalloc(image->ncolors * sizeof(int)); BOOL *spal = dmCalloc(image->ncolors, sizeof(BOOL)); - int index, xc, yc; + int index, xc, yc, nncolors = image->ncolors; if (npal == NULL || spal == NULL || dpal == NULL) { @@ -778,7 +778,7 @@ dpal[map->to] = n; spal[n] = TRUE; found = TRUE; - break; +// break; } } @@ -822,12 +822,13 @@ dmMsg(3, "Creating new palette.\n"); for (index = 0; index < image->ncolors; index++) { - dmMsg(4, "%d -> %d\n", dpal[index], index); if (dpal[index] >= 0 && dpal[index] < image->ncolors) { memcpy(&npal[index], &(image->pal[dpal[index]]), sizeof(DMColor)); + nncolors = index; } } + // Remap image dmMsg(1, "Remapping image ...\n"); @@ -841,12 +842,15 @@ { dp[xc] = dpal[col]; } + else + dp[xc] = 0; } } // Set new palette, free memory dmFree(image->pal); image->pal = npal; + image->ncolors = nncolors; dmFree(spal); dmFree(dpal); return DMERR_OK;