Mercurial > hg > dmlib
changeset 478:7c7a57590236
Calculate number of remapped colors.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Wed, 07 Nov 2012 03:03:01 +0200 |
parents | 0fd0e301b6fc |
children | b768bfb0b364 |
files | gfxconv.c |
diffstat | 1 files changed, 7 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- 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;