Mercurial > hg > dmlib
comparison tools/gfxconv.c @ 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 |
comparison
equal
deleted
inserted
replaced
2466:213ce6d400dc | 2467:a11ef670bd99 |
---|---|
1065 fprintf(outFile, "\n"); | 1065 fprintf(outFile, "\n"); |
1066 } | 1066 } |
1067 } | 1067 } |
1068 | 1068 |
1069 | 1069 |
1070 BOOL dmExactCompareColor(const DMColor *c1, const DMColor *c2, const BOOL alpha) | |
1071 { | |
1072 if (c1->r == c2->r && | |
1073 c1->g == c2->g && | |
1074 c1->b == c2->b) | |
1075 return alpha ? (c1->a == c2->a) : TRUE; | |
1076 else | |
1077 return FALSE; | |
1078 } | |
1079 | |
1080 | |
1070 int dmRemoveUnusedImageColors(DMImage **pdst, const DMImage *src) | 1081 int dmRemoveUnusedImageColors(DMImage **pdst, const DMImage *src) |
1071 { | 1082 { |
1072 DMPalette *tmpPal = NULL; | 1083 DMPalette *tmpPal = NULL; |
1073 int *mapping = dmMalloc(src->pal->ncolors * sizeof(int)); | 1084 int *mapping = dmMalloc(src->pal->ncolors * sizeof(int)); |
1074 BOOL *mapped = dmMalloc(src->pal->ncolors * sizeof(BOOL)); | 1085 BOOL *mapped = dmMalloc(src->pal->ncolors * sizeof(BOOL)); |
1130 if (map->triplet) | 1141 if (map->triplet) |
1131 { | 1142 { |
1132 BOOL found = FALSE; | 1143 BOOL found = FALSE; |
1133 for (n = 0; n < src->pal->ncolors; n++) | 1144 for (n = 0; n < src->pal->ncolors; n++) |
1134 { | 1145 { |
1135 if (dmCompareColor(&(src->pal->colors[n]), &(map->color), map->alpha)) | 1146 if (dmExactCompareColor(&(src->pal->colors[n]), &(map->color), map->alpha)) |
1136 { | 1147 { |
1137 dmMsg(3, "RGBA match #%02x%02x%02x%02x: %d -> %d\n", | 1148 dmMsg(3, "RGBA match #%02x%02x%02x%02x: %d -> %d\n", |
1138 map->color.r, map->color.g, map->color.b, map->color.a, | 1149 map->color.r, map->color.g, map->color.b, map->color.a, |
1139 n, | 1150 n, |
1140 map->to); | 1151 map->to); |