new function Set_image_mode() to set image mode in Load_XXX() functions

This commit is contained in:
Thomas Bernard 2018-12-10 21:34:35 +01:00
parent 2d392fb7b1
commit 2a6f0e3a27
No known key found for this signature in database
GPG Key ID: 0FF11B67A5C0863C
4 changed files with 17 additions and 26 deletions

View File

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

View File

@ -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.

View File

@ -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

View File

@ -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; ty<context->Height; 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));
}