Fix issue 496: Some animated GIF images don't load well. Also fixed the handling of transparency in preview (fileselector) and loading anim GIF as a brush loads first frame.
git-svn-id: svn://pulkomandy.tk/GrafX2/trunk@1969 416bcca6-2ee7-4201-b75f-2eb2f807beb1
This commit is contained in:
parent
2aa72730ad
commit
7613093df9
@ -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
|
||||
|
||||
@ -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,7 +387,7 @@ 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;
|
||||
|
||||
|
||||
@ -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);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user