From e423b5fb9243346b876eb25aeb620447a119fb1c Mon Sep 17 00:00:00 2001 From: Yves Rizoud Date: Mon, 1 Mar 2010 22:49:55 +0000 Subject: [PATCH] Fix issue 323: X-Invert didn't remap (it worked fine in 2.1). In Palette screen, fix Color reduce that only checked for used colors in visible image (instead of all layers) git-svn-id: svn://pulkomandy.tk/GrafX2/trunk@1368 416bcca6-2ee7-4201-b75f-2eb2f807beb1 --- misc.c | 24 +++++++++++++++--------- palette.c | 4 ++-- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/misc.c b/misc.c index d48cf531..4abf635f 100644 --- a/misc.c +++ b/misc.c @@ -46,25 +46,31 @@ word Count_used_colors(dword* usage) { int nb_pixels = 0; - Uint8* current_pixel = Main_screen; + Uint8* current_pixel; Uint8 color; word nb_colors = 0; int i; + int layer; for (i = 0; i < 256; i++) usage[i]=0; // Compute total number of pixels in the picture nb_pixels = Main_image_height * Main_image_width; - // For each pixel in picture - for (i = 0; i < nb_pixels; i++) + // For each layer + for (layer = 0; layer < Main_backups->Pages->Nb_layers; layer++) { - color=*current_pixel; // get color in picture for this pixel - - usage[color]++; // add it to the counter - - // go to next pixel - current_pixel++; + current_pixel = Main_backups->Pages->Image[layer]; + // For each pixel in picture + for (i = 0; i < nb_pixels; i++) + { + color=*current_pixel; // get color in picture for this pixel + + usage[color]++; // add it to the counter + + // go to next pixel + current_pixel++; + } } // count the total number of unique used colors diff --git a/palette.c b/palette.c index 4236a006..a4456d5e 100644 --- a/palette.c +++ b/palette.c @@ -1838,7 +1838,7 @@ void Button_Palette(void) Set_red(i,backup_palette[temp_color].R,working_palette); Set_green (i,backup_palette[temp_color].G,working_palette); Set_blue (i,backup_palette[temp_color].B,working_palette); - if (clicked_button==22) + if (clicked_button==21) { conversion_table[i]=temp_color; conversion_table[temp_color]=i; @@ -1850,7 +1850,7 @@ void Button_Palette(void) } Draw_all_palette_sliders(red_slider,green_slider,blue_slider,working_palette,block_start,block_end); // Si on est en X-Invert, on remap l'image (=> on fait aussi 1 backup) - if (clicked_button==22) + if (clicked_button==21) { if (!image_is_backed_up) {