Mercurial > hg > dmlib
changeset 2467:a11ef670bd99
Move dmCompareColor() from libgfx to gfxconv as it is used only there,
rename to dmExactCompareColor().
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Thu, 16 Apr 2020 15:00:18 +0300 |
parents | 213ce6d400dc |
children | 16c57206cef7 |
files | tools/gfxconv.c tools/libgfx.c tools/libgfx.h |
diffstat | 3 files changed, 12 insertions(+), 13 deletions(-) [+] |
line wrap: on
line diff
--- a/tools/gfxconv.c Thu Apr 16 14:35:41 2020 +0300 +++ b/tools/gfxconv.c Thu Apr 16 15:00:18 2020 +0300 @@ -1067,6 +1067,17 @@ } +BOOL dmExactCompareColor(const DMColor *c1, const DMColor *c2, const BOOL alpha) +{ + if (c1->r == c2->r && + c1->g == c2->g && + c1->b == c2->b) + return alpha ? (c1->a == c2->a) : TRUE; + else + return FALSE; +} + + int dmRemoveUnusedImageColors(DMImage **pdst, const DMImage *src) { DMPalette *tmpPal = NULL; @@ -1132,7 +1143,7 @@ BOOL found = FALSE; for (n = 0; n < src->pal->ncolors; n++) { - if (dmCompareColor(&(src->pal->colors[n]), &(map->color), map->alpha)) + if (dmExactCompareColor(&(src->pal->colors[n]), &(map->color), map->alpha)) { dmMsg(3, "RGBA match #%02x%02x%02x%02x: %d -> %d\n", map->color.r, map->color.g, map->color.b, map->color.a,
--- a/tools/libgfx.c Thu Apr 16 14:35:41 2020 +0300 +++ b/tools/libgfx.c Thu Apr 16 15:00:18 2020 +0300 @@ -108,17 +108,6 @@ } -BOOL dmCompareColor(const DMColor *c1, const DMColor *c2, const BOOL alpha) -{ - if (c1->r == c2->r && - c1->g == c2->g && - c1->b == c2->b) - return alpha ? (c1->a == c2->a) : TRUE; - else - return FALSE; -} - - int dmImageGetBytesPerPixel(const int format) { switch (format)
--- a/tools/libgfx.h Thu Apr 16 14:35:41 2020 +0300 +++ b/tools/libgfx.h Thu Apr 16 15:00:18 2020 +0300 @@ -161,7 +161,6 @@ // // Palette handling // -BOOL dmCompareColor(const DMColor *c1, const DMColor *c2, const BOOL alpha); int dmPaletteAlloc(DMPalette **ppal, const int ncolors, const int ctransp); int dmPaletteResize(DMPalette **ppal, const int ncolors); void dmPaletteFree(DMPalette *pal);