diff --git a/buttons.c b/buttons.c index 74cbb70b..4cb44869 100644 --- a/buttons.c +++ b/buttons.c @@ -394,7 +394,7 @@ void Button_Hide_menu(void) { Menu_is_visible=1; Pixel_in_menu=Pixel_in_toolbar; - Menu_Y=Screen_height-(MENU_HEIGHT*Menu_factor_Y); + Menu_Y=Screen_height-(Menu_height*Menu_factor_Y); Compute_magnifier_data(); if (Main_magnifier_mode) diff --git a/global.h b/global.h index 0f6ff913..6e6b780a 100644 --- a/global.h +++ b/global.h @@ -474,9 +474,11 @@ GFX2_GLOBAL short Brush_rotation_center_Y; /// Boolean, true if the menu has to be displayed. GFX2_GLOBAL byte Menu_is_visible; +/// Height of the menu, when it's displayed +GFX2_GLOBAL word Menu_height; /// /// Y position (in screen coordinates) where the menu begins. -/// This is always either ::Screen_height (when menu is hidden) or (::Screen_height - ::MENU_HEIGHT) +/// This is always either ::Screen_height (when menu is hidden) or (::Screen_height - ::Menu_height) /// As a result, the drawing algoritm always draws the image from 0 to ::Menu_Y-1 GFX2_GLOBAL word Menu_Y; /// Y position of the status bar (in screen coordinates) diff --git a/graph.c b/graph.c index fc1c2f35..5674d025 100644 --- a/graph.c +++ b/graph.c @@ -531,7 +531,7 @@ int Init_mode_video(int width, int height, int fullscreen, int pix_ratio) Menu_Y = Screen_height; if (Menu_is_visible) - Menu_Y -= MENU_HEIGHT * Menu_factor_Y; + Menu_Y -= Menu_height * Menu_factor_Y; Menu_status_Y = Screen_height-(Menu_factor_Y<<3); Adjust_mouse_sensitivity(fullscreen); diff --git a/loadsave.c b/loadsave.c index f2508cd1..82388cf1 100644 --- a/loadsave.c +++ b/loadsave.c @@ -126,22 +126,22 @@ void Save_PNG(void); void Init_preview(short width,short height,long size,int format,enum PIXEL_RATIO ratio); T_Format File_formats[NB_KNOWN_FORMATS] = { - {"pkm", Test_PKM, Load_PKM, Save_PKM, 1, 1}, - {"lbm", Test_LBM, Load_LBM, Save_LBM, 1, 0}, - {"gif", Test_GIF, Load_GIF, Save_GIF, 1, 1}, - {"bmp", Test_BMP, Load_BMP, Save_BMP, 1, 0}, - {"pcx", Test_PCX, Load_PCX, Save_PCX, 1, 0}, - {"img", Test_IMG, Load_IMG, Save_IMG, 1, 0}, - {"sc?", Test_SCx, Load_SCx, Save_SCx, 1, 0}, - {"pi1", Test_PI1, Load_PI1, Save_PI1, 1, 0}, - {"pc1", Test_PC1, Load_PC1, Save_PC1, 1, 0}, - {"cel", Test_CEL, Load_CEL, Save_CEL, 1, 0}, - {"neo", Test_NEO, Load_NEO, Save_NEO, 1, 0}, - {"kcf", Test_KCF, Load_KCF, Save_KCF, 0, 0}, - {"pal", Test_PAL, Load_PAL, Save_PAL, 0, 0}, - {"c64", Test_C64, Load_C64, Save_C64, 1, 1}, + {"pkm", Test_PKM, Load_PKM, Save_PKM, 1, 1, 0}, + {"lbm", Test_LBM, Load_LBM, Save_LBM, 1, 0, 0}, + {"gif", Test_GIF, Load_GIF, Save_GIF, 1, 1, 1}, + {"bmp", Test_BMP, Load_BMP, Save_BMP, 1, 0, 0}, + {"pcx", Test_PCX, Load_PCX, Save_PCX, 1, 0, 0}, + {"img", Test_IMG, Load_IMG, Save_IMG, 1, 0, 0}, + {"sc?", Test_SCx, Load_SCx, Save_SCx, 1, 0, 0}, + {"pi1", Test_PI1, Load_PI1, Save_PI1, 1, 0, 0}, + {"pc1", Test_PC1, Load_PC1, Save_PC1, 1, 0, 0}, + {"cel", Test_CEL, Load_CEL, Save_CEL, 1, 0, 0}, + {"neo", Test_NEO, Load_NEO, Save_NEO, 1, 0, 0}, + {"kcf", Test_KCF, Load_KCF, Save_KCF, 0, 0, 0}, + {"pal", Test_PAL, Load_PAL, Save_PAL, 0, 0, 0}, + {"c64", Test_C64, Load_C64, Save_C64, 1, 1, 0}, #ifndef __no_pnglib__ - {"png", Test_PNG, Load_PNG, Save_PNG, 1, 1} + {"png", Test_PNG, Load_PNG, Save_PNG, 1, 1, 0} #endif }; @@ -742,7 +742,28 @@ void Save_image(byte image) // sauver le format du fichier: (Est-ce vraiment utile??? Je ne crois pas!) File_error=1; - Read_pixel_function=(image)?Read_pixel_from_current_screen:Read_pixel_from_brush; + if (image) + { + if (!File_formats[Main_fileformat-1].Supports_layers + && Main_backups->Pages->Nb_layers > 1) + { + if (! Confirmation_box("This format will save a flattened copy.")) + { + // File_error is already set to 1. + return; + } + Read_pixel_function=Read_pixel_from_current_screen; + } + else + { + Read_pixel_function=Read_pixel_from_current_layer; + } + } + else + { + Read_pixel_function=Read_pixel_from_brush; + } + File_formats[Main_fileformat-1].Save(); @@ -3416,9 +3437,6 @@ void Save_GIF(void) byte old_current_layer=Main_current_layer; /////////////////////////////////////////////////// FIN DES DECLARATIONS // - - if (Read_pixel_function==Read_pixel_from_current_screen) - Read_pixel_function=Read_pixel_from_current_layer; File_error=0; @@ -3714,8 +3732,9 @@ void Save_GIF(void) else File_error=1; - // Restore original layer + // Restore original index of current layer Main_current_layer = old_current_layer; + } diff --git a/loadsave.h b/loadsave.h index 93025ae8..90ca97f9 100644 --- a/loadsave.h +++ b/loadsave.h @@ -40,12 +40,13 @@ void Save_image(byte image); /// Data for an image file format. typedef struct { - char *Extension; ///< Three-letter file extension - Func_action Test; ///< Function which tests if the file is of this format - Func_action Load; ///< Function which loads an image of this format - Func_action Save; ///< Function which saves an image of this format - byte Backup_done; ///< Boolean, true if this format saves all the image, and considers it backed up. Set false for formats which only save the palette. - byte Comment; ///< This file format allows a text comment + char *Extension; ///< Three-letter file extension + Func_action Test; ///< Function which tests if the file is of this format + Func_action Load; ///< Function which loads an image of this format + Func_action Save; ///< Function which saves an image of this format + byte Backup_done; ///< Boolean, true if this format saves all the image, and considers it backed up. Set false for formats which only save the palette. + byte Comment; ///< This file format allows a text comment + byte Supports_layers; ///< Boolean, true if this format preserves layers on saving } T_Format; /// Array of the known file formats diff --git a/main.c b/main.c index 2e9e3a67..73c4cf8b 100644 --- a/main.c +++ b/main.c @@ -462,6 +462,7 @@ int Init_program(int argc,char * argv[]) // Données sur l'état du menu: Pixel_in_menu=Pixel_in_toolbar; Menu_is_visible=1; + Menu_height=MENU_HEIGHT; // Données sur les couleurs et la palette: First_color_in_palette=0; // Données sur le curseur: diff --git a/misc.c b/misc.c index bcee087d..c0fb6e65 100644 --- a/misc.c +++ b/misc.c @@ -257,21 +257,16 @@ byte Read_pixel_from_current_layer(word x,word y) return *((y)*Main_image_width+(x)+Main_backups->Pages->Image[Main_current_layer]); } -void Replace_a_color(byte old_color, byte New_color) +void Replace_a_color(byte old_color, byte new_color) { - byte* pixel_on_layer; - byte* pixel_visible; - - // pour chaque pixel : - pixel_visible=Main_screen; - for(pixel_on_layer = Main_backups->Pages->Image[Main_current_layer];pixel_on_layer < Main_screen + Main_image_height * Main_image_width;pixel_on_layer++,pixel_visible++) - { - if (*pixel_on_layer == old_color) - { - *pixel_on_layer = New_color; - *pixel_visible = New_color; - } - } + word x; + word y; + + // Update all pixels + for (y=0; y