diff --git a/src/fileformats.c b/src/fileformats.c index e2457793..8f8d25a5 100644 --- a/src/fileformats.c +++ b/src/fileformats.c @@ -2057,19 +2057,10 @@ void Load_GIF(T_IO_Context * context) disposal_method = (GCE.Packed_fields >> 2) & 7; last_delay = GCE.Delay_time; context->Transparent_color= GCE.Transparent_color; - if (GCE.Packed_fields & 1) - { - if (number_LID == 0) - context->Background_transparent = 1; - } - else - { - if (number_LID == 0) - context->Background_transparent = 0; - } - is_transparent = - (previous_disposal_method==DISPOSAL_METHOD_DO_NOT_DISPOSE - ||previous_disposal_method==DISPOSAL_METHOD_UNDEFINED); + is_transparent = GCE.Packed_fields & 1; + if (number_LID == 0) + context->Background_transparent = is_transparent; + is_transparent &= is_looping; } else File_error=2; @@ -2219,20 +2210,13 @@ void Load_GIF(T_IO_Context * context) } else { - if (context->Type == CONTEXT_MAIN_IMAGE) - memset( - Main_backups->Pages->Image[Main_current_layer].Pixels, - LSDB.Backcol, - Main_backups->Pages->Width*Main_backups->Pages->Height); + Fill_canvas(context, LSDB.Backcol); } } else { - if (context->Type == CONTEXT_MAIN_IMAGE) - memset( - Main_backups->Pages->Image[Main_current_layer].Pixels, - LSDB.Backcol, - Main_backups->Pages->Width*Main_backups->Pages->Height); + // First frame/layer, fill canvas with backcolor + Fill_canvas(context, LSDB.Backcol); } // Duration was set in the previously loaded GCE Set_frame_duration(context, last_delay*10); @@ -2286,11 +2270,11 @@ void Load_GIF(T_IO_Context * context) previous_width); } } - previous_height=IDB.Image_height; - previous_width=IDB.Image_width; - previous_pos_x=IDB.Pos_X; - previous_pos_y=IDB.Pos_Y; } + previous_height=IDB.Image_height; + previous_width=IDB.Image_width; + previous_pos_x=IDB.Pos_X; + previous_pos_y=IDB.Pos_Y; Palette_loaded(context); @@ -2387,6 +2371,11 @@ void Load_GIF(T_IO_Context * context) { goto early_exit; } + // Same with brush + if (context->Type == CONTEXT_BRUSH && is_looping) + { + goto early_exit; + } } // Le fichier contenait un IDB else diff --git a/src/loadsave.c b/src/loadsave.c index 938914a1..818a8c07 100644 --- a/src/loadsave.c +++ b/src/loadsave.c @@ -241,6 +241,28 @@ void Set_pixel(T_IO_Context *context, short x_pos, short y_pos, byte color) } +void Fill_canvas(T_IO_Context *context, byte color) +{ + switch (context->Type) + { + case CONTEXT_PREVIEW: + if (context->Current_layer!=0) + return; + memset(context->Preview_bitmap, color, PREVIEW_WIDTH*PREVIEW_HEIGHT*Menu_factor_X*Menu_factor_Y); + break; + case CONTEXT_MAIN_IMAGE: + memset( + Main_backups->Pages->Image[Main_current_layer].Pixels, + color, + Main_backups->Pages->Width*Main_backups->Pages->Height); + break; + case CONTEXT_BRUSH: + memset(context->Buffer_image, color, (long)context->Height*context->Pitch); + break; + case CONTEXT_SURFACE: + break; + } +} void Palette_loaded(T_IO_Context *context) { @@ -365,10 +387,10 @@ void Pre_load(T_IO_Context *context, short width, short height, long file_size, case CONTEXT_PREVIEW: // Préparation du chargement d'une preview: - context->Preview_bitmap=malloc(PREVIEW_WIDTH*PREVIEW_HEIGHT*Menu_factor_X*Menu_factor_Y); + context->Preview_bitmap=calloc(1, PREVIEW_WIDTH*PREVIEW_HEIGHT*Menu_factor_X*Menu_factor_Y); if (!context->Preview_bitmap) File_error=1; - + // Affichage des données "Image size:" if ((width<10000) && (height<10000)) { diff --git a/src/loadsave.h b/src/loadsave.h index 9ce5ce12..f4a7e46f 100644 --- a/src/loadsave.h +++ b/src/loadsave.h @@ -207,6 +207,8 @@ void Pre_load(T_IO_Context *context, short width, short height, long file_size, void Palette_loaded(T_IO_Context *context); /// Generic cleanup done on end of loading (ex: color-conversion from the temporary 24b buffer) //void Post_load(T_IO_Context *context); +/// Fill the entire current layer/frame of an image being loaded with a color. +void Fill_canvas(T_IO_Context *context, byte color); /// Query the color of a pixel (to save) byte Get_pixel(T_IO_Context *context, short x, short y);