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) {