diff --git a/src/fileformats.c b/src/fileformats.c index 8760e747..45abd72e 100644 --- a/src/fileformats.c +++ b/src/fileformats.c @@ -2007,11 +2007,7 @@ void Load_IFF(T_IO_Context * context) context->Background_transparent = header.Mask == 2; context->Transparent_color = context->Background_transparent ? header.Transp_col : 0; - if (context->Type == CONTEXT_MAIN_IMAGE) - { - Main.backups->Pages->Image_mode = IMAGE_MODE_ANIMATION; - Update_screen_targets(); - } + Set_image_mode(context, IMAGE_MODE_ANIMATION); if (iff_format == FORMAT_LBM) // "ILBM": InterLeaved BitMap { @@ -2752,11 +2748,7 @@ void Load_INFO(T_IO_Context * context) if (img_index == 1) { Pre_load(context, width, height,file_size,FORMAT_INFO,PIXEL_SIMPLE, bpp); - if (context->Type == CONTEXT_MAIN_IMAGE) - { - Main.backups->Pages->Image_mode = IMAGE_MODE_ANIMATION; - Update_screen_targets(); - } + Set_image_mode(context, IMAGE_MODE_ANIMATION); has_NewIcons = 1; } else @@ -2884,11 +2876,7 @@ void Load_INFO(T_IO_Context * context) memcpy(context->Palette, amigaOS2x_pal, sizeof(amigaOS2x_pal)); Pre_load(context, header.Width, header.Height,file_size,FORMAT_INFO,PIXEL_SIMPLE, imgheaders[0].Depth); - if (context->Type == CONTEXT_MAIN_IMAGE) - { - Main.backups->Pages->Image_mode = IMAGE_MODE_ANIMATION; - Update_screen_targets(); - } + Set_image_mode(context, IMAGE_MODE_ANIMATION); for (img_count = 0; img_count < 2 && buffers[img_count] != NULL; img_count++) { if (img_count > 0) @@ -4193,11 +4181,7 @@ void Load_GIF(T_IO_Context * context) is_looping=1; // The well-known Netscape extension. // Load as an animation - if (context->Type == CONTEXT_MAIN_IMAGE) - { - Main.backups->Pages->Image_mode = IMAGE_MODE_ANIMATION; - Update_screen_targets(); - } + Set_image_mode(context, IMAGE_MODE_ANIMATION); // Skip sub-block do { diff --git a/src/loadsave.c b/src/loadsave.c index 3e4c79e0..7596e0f2 100644 --- a/src/loadsave.c +++ b/src/loadsave.c @@ -312,6 +312,15 @@ int Get_frame_duration(T_IO_Context *context) } } +void Set_image_mode(T_IO_Context *context, enum IMAGE_MODES mode) +{ + if (context->Type == CONTEXT_MAIN_IMAGE) + { + Main.backups->Pages->Image_mode = mode; + Update_screen_targets(); + } +} + /// /// Generic allocation and similar stuff, done at beginning of image load, /// as soon as size is known. diff --git a/src/loadsave.h b/src/loadsave.h index 7efc0873..76603710 100644 --- a/src/loadsave.h +++ b/src/loadsave.h @@ -230,6 +230,8 @@ void Set_saving_layer(T_IO_Context *context, int layer); void Set_frame_duration(T_IO_Context *context, int duration); /// Function to call to get an image's duration for saving int Get_frame_duration(T_IO_Context *context); +/// Function to set a specific image mode +void Set_image_mode(T_IO_Context *context, enum IMAGE_MODES mode); // ================================================================= // What follows here are the definitions of functions and data diff --git a/src/miscfileformats.c b/src/miscfileformats.c index 4036e97e..f229cda4 100644 --- a/src/miscfileformats.c +++ b/src/miscfileformats.c @@ -4221,7 +4221,7 @@ void Load_CM5(T_IO_Context* context) if (context->Type == CONTEXT_MAIN_IMAGE) { - Main.backups->Pages->Image_mode = IMAGE_MODE_MODE5; + Set_image_mode(context, IMAGE_MODE_MODE5); // Fill layer with color we just read (Layer 1 - INK 0) for(ty=0; tyHeight; ty++) @@ -4944,11 +4944,7 @@ void Load_FLI(T_IO_Context * context) if (current_frame == 0) { Pre_load(context, header.width,header.height,file_size,FORMAT_FLI,PIXEL_SIMPLE,header.depth); - if (context->Type == CONTEXT_MAIN_IMAGE) - { - Main.backups->Pages->Image_mode = IMAGE_MODE_ANIMATION; - Update_screen_targets(); - } + Set_image_mode(context, IMAGE_MODE_ANIMATION); if (Config.Clear_palette) memset(context->Palette,0,sizeof(T_Palette)); }