forked from hkc/cc-stuff
1
0
Fork 0

Now only calculate color difference once for each palette entry

Not clear whether it is more optimal
This commit is contained in:
Vftdan 2024-10-02 19:43:30 +02:00
parent d765e88679
commit 0e3bf6c910
1 changed files with 10 additions and 3 deletions

View File

@ -578,16 +578,23 @@ void convert_2x3(const struct image_pal *img, struct cc_char *characters) {
void convert_8x11(const struct image_pal *img, struct cc_char *characters) {
int w = img->w / 8, h = img->h / 11;
float palette_self_diffs[0x100][0x10] = {{(float) 0xffffff}};
for (int input_color = 0x0; input_color < 0x100 && input_color < img->palette_size; input_color++) {
for (int output_color = 0x0; output_color < 0x10 && output_color < img->palette_size; output_color++) {
palette_self_diffs[input_color][output_color] = get_color_difference(img->palette[input_color], img->palette[output_color]);
}
}
for (int y = 0; y < h; y++) {
for (int x = 0; x < w; x++) {
float chunk_palette_diffs[8][11][0x10] = {{{(float) 0xffffff}}};
for (int ox = 0; ox < 8; ox++) {
for (int oy = 0; oy < 11; oy++) {
union color pixel = img->palette[img->pixels[
uint8_t pixel_unresolved = img->pixels[
ox + (x + (y * 11 + oy) * w) * 8
]];
];
for (int color = 0x0; color < 0x10 && color < img->palette_size; color++) {
chunk_palette_diffs[ox][oy][color] = get_color_difference(pixel, img->palette[color]);
chunk_palette_diffs[ox][oy][color] = palette_self_diffs[pixel_unresolved][color];
}
}
}