Merged trunk into branches/mode5 (=update mode5 branch to latest)
git-svn-id: svn://pulkomandy.tk/GrafX2/branches/cpcmode5@1785 416bcca6-2ee7-4201-b75f-2eb2f807beb1
This commit is contained in:
@@ -628,7 +628,8 @@ void Load_image(T_IO_Context *context)
|
||||
if (File_error>0)
|
||||
{
|
||||
fprintf(stderr,"Unable to load file %s!\n",context->File_name);
|
||||
Error(0);
|
||||
if (context->Type!=CONTEXT_SURFACE)
|
||||
Error(0);
|
||||
}
|
||||
|
||||
// Post-load
|
||||
@@ -693,14 +694,35 @@ void Load_image(T_IO_Context *context)
|
||||
memset(color_usage,0,sizeof(color_usage));
|
||||
if (Count_used_colors(color_usage)<252)
|
||||
{
|
||||
int gui_index=0;
|
||||
int c;
|
||||
for (c=255; c>=0 && gui_index<4; c--)
|
||||
int gui_index;
|
||||
// From white to black
|
||||
for (gui_index=3; gui_index>=0; gui_index--)
|
||||
{
|
||||
if (color_usage[c]==0)
|
||||
int c;
|
||||
T_Components gui_color;
|
||||
|
||||
gui_color=*Favorite_GUI_color(gui_index);
|
||||
// Try find a very close match (ignore last 2 bits)
|
||||
for (c=255; c>=0; c--)
|
||||
{
|
||||
context->Palette[c]=*Favorite_GUI_color(gui_index);
|
||||
gui_index++;
|
||||
if ((context->Palette[c].R|3) == (gui_color.R|3)
|
||||
&& (context->Palette[c].G|3) == (gui_color.G|3)
|
||||
&& (context->Palette[c].B|3) == (gui_color.B|3) )
|
||||
break;
|
||||
}
|
||||
if (c<0) // Not found
|
||||
{
|
||||
// Find an unused slot at end of palette
|
||||
for (c=255; c>=0; c--)
|
||||
{
|
||||
if (color_usage[c]==0)
|
||||
{
|
||||
context->Palette[c]=gui_color;
|
||||
// Tag as a used color
|
||||
color_usage[c]=1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user