version 1.5 | | version 1.6 |
---|
| | |
/* | | /* |
* static char *rcsid_xutil_c = | | * static char *rcsid_xutil_c = |
* "$Id: xutil.c,v 1.5 2000/12/18 08:00:26 cvs Exp $"; | | * "$Id: xutil.c,v 1.6 2001/03/10 08:27:36 mwedel Exp $"; |
*/ | | */ |
| | |
/* | | /* |
| | |
* can be null. | | * can be null. |
*/ | | */ |
| | |
| | /* Useful when trying to optimize load time some */ |
| | #define IMAGE_TIME_LOAD |
| | |
int ReadImages(Display *gdisp, Pixmap **pixmaps, Pixmap **masks, | | int ReadImages(Display *gdisp, Pixmap **pixmaps, Pixmap **masks, |
Colormap *cmap, enum DisplayMode type) { | | Colormap *cmap, enum DisplayMode type) { |
| | |
| | |
int use_private_cmap=0,num, compressed, len,i, error; | | int use_private_cmap=0,num, compressed, len,i, error; |
FILE *infile; | | FILE *infile; |
char *cp, databuf[HUGE_BUF], filename[MAX_BUF]; | | char *cp, databuf[HUGE_BUF], filename[MAX_BUF]; |
| | #ifdef IMAGE_TIME_LOAD |
| | time_t start_time = time(NULL); |
| | #endif |
| | |
/* This function is called before the game gc's are created. So | | /* This function is called before the game gc's are created. So |
* we create one for our own use here. | | * we create one for our own use here. |
| | |
sprintf(filename,"%s/crossfire.xpm",settings.datadir); | | sprintf(filename,"%s/crossfire.xpm",settings.datadir); |
else if (type==Dm_Bitmap) | | else if (type==Dm_Bitmap) |
sprintf(filename,"%s/crossfire.xbm",settings.datadir); | | sprintf(filename,"%s/crossfire.xbm",settings.datadir); |
else if (type==Dm_Png) | | else if (type==Dm_Png) { |
sprintf(filename,"%s/crossfire.png",settings.datadir); | | sprintf(filename,"%s/crossfire.png",settings.datadir); |
| | #ifdef HAVE_LIBPNG |
| | init_pngx_loader(gdisp); |
| | #endif |
| | } |
| | |
if ((infile = open_and_uncompress(filename,0,&compressed))==NULL) { | | if ((infile = open_and_uncompress(filename,0,&compressed))==NULL) { |
LOG(llevError,"Unable to open %s\n", filename); | | LOG(llevError,"Unable to open %s\n", filename); |
| | |
#ifdef HAVE_LIBPNG | | #ifdef HAVE_LIBPNG |
unsigned long x,y; | | unsigned long x,y; |
if (png_to_xpixmap(gdisp, root, databuf, len, | | if (png_to_xpixmap(gdisp, root, databuf, len, |
&(*pixmaps)[num], &(*masks)[num], *cmap, &x, &y)) { | | &(*pixmaps)[num], &(*masks)[num], cmap, &x, &y)) { |
| | |
LOG(llevError,"Error loading png file.\n"); | | LOG(llevError,"Error loading png file.\n"); |
} | | } |
| | |
pixmaps[i] = pixmaps[blank_face->number]; | | pixmaps[i] = pixmaps[blank_face->number]; |
} | | } |
LOG(llevDebug,"done.\n"); | | LOG(llevDebug,"done.\n"); |
| | #ifdef IMAGE_TIME_LOAD |
| | fprintf(stderr,"Creation of images took %ld seconds\n", time(NULL) - start_time); |
| | #endif |
return use_private_cmap; | | return use_private_cmap; |
return 0; /* Prevents some warning messages */ | | |
} | | } |
| | |
/* This frees all the pixmaps. This not only makes for better code, | | /* This frees all the pixmaps. This not only makes for better code, |