Reverted the icon-loading code to SDL_image, using more solid code to handle both 8bit and hi-color icons
git-svn-id: svn://pulkomandy.tk/GrafX2/trunk@1248 416bcca6-2ee7-4201-b75f-2eb2f807beb1
This commit is contained in:
parent
84ac0df49c
commit
e351605a24
20
main.c
20
main.c
@ -509,22 +509,32 @@ int Init_program(int argc,char * argv[])
|
|||||||
char icon_path[MAX_PATH_CHARACTERS];
|
char icon_path[MAX_PATH_CHARACTERS];
|
||||||
SDL_Surface * icon;
|
SDL_Surface * icon;
|
||||||
sprintf(icon_path, "%s%s", Data_directory, "gfx2.gif");
|
sprintf(icon_path, "%s%s", Data_directory, "gfx2.gif");
|
||||||
icon = Load_surface(icon_path);
|
icon = IMG_Load(icon_path);
|
||||||
if (icon)
|
if (icon && icon->w == 32 && icon->h == 32)
|
||||||
|
{
|
||||||
|
Uint32 pink;
|
||||||
|
pink = SDL_MapRGB(icon->format, 255, 0, 255);
|
||||||
|
|
||||||
|
if (icon->format->BitsPerPixel == 8)
|
||||||
|
{
|
||||||
|
SDL_SetColorKey(icon, SDL_SRCCOLORKEY, pink);
|
||||||
|
SDL_WM_SetIcon(icon,NULL);
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
byte *icon_mask;
|
byte *icon_mask;
|
||||||
int x,y;
|
int x,y;
|
||||||
Uint32 pink;
|
|
||||||
|
|
||||||
pink = SDL_MapRGB(icon->format, 255, 0, 255);
|
|
||||||
icon_mask=malloc(128);
|
icon_mask=malloc(128);
|
||||||
memset(icon_mask,0,128);
|
memset(icon_mask,0,128);
|
||||||
for (y=0;y<32;y++)
|
for (y=0;y<32;y++)
|
||||||
for (x=0;x<32;x++)
|
for (x=0;x<32;x++)
|
||||||
if (((byte *)(icon->pixels))[(y*32+x)] != pink)
|
if (Get_SDL_pixel_hicolor(icon, x, y) != pink)
|
||||||
icon_mask[(y*32+x)/8] |=0x80>>(x&7);
|
icon_mask[(y*32+x)/8] |=0x80>>(x&7);
|
||||||
SDL_WM_SetIcon(icon,icon_mask);
|
SDL_WM_SetIcon(icon,icon_mask);
|
||||||
free(icon_mask);
|
free(icon_mask);
|
||||||
|
}
|
||||||
|
|
||||||
SDL_FreeSurface(icon);
|
SDL_FreeSurface(icon);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user