version 1.3 | | version 1.4 |
---|
| | |
/* | | /* |
* static char *rcsid_xutil_c = | | * static char *rcsid_xutil_c = |
* "$Id: xutil.c,v 1.3 2000/05/13 23:44:43 cvs Exp $"; | | * "$Id: xutil.c,v 1.4 2000/12/04 07:19:56 cvs Exp $"; |
*/ | | */ |
| | |
/* | | /* |
| | |
The author can be reached via e-mail to mwedel@scruz.net | | The author can be reached via e-mail to mwedel@scruz.net |
*/ | | */ |
| | |
| | |
| | #include <autoconf.h> |
| | /* Stupid pngconf.h file has a check to see if _SETJMP_H is |
| | * already defined, and if so, it generates a compilation error. |
| | * I have no idea what they were thinking - wasn't th point of those |
| | * defines so that you didn't need to worry about order or including |
| | * the same file multiple times? |
| | */ |
| | #ifdef HAVE_LIBPNG |
| | #include "png.c" |
| | #endif |
| | |
#include <global.h> | | #include <global.h> |
#include <funcpoint.h> | | #include <funcpoint.h> |
#include <loader.h> | | #include <loader.h> |
| | |
| | |
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) { |
#ifdef HAVE_LIBXPM | | |
| | |
Window root = RootWindow (gdisp,DefaultScreen(gdisp)); | | Window root = RootWindow (gdisp,DefaultScreen(gdisp)); |
XpmAttributes xpmatribs; | | XpmAttributes xpmatribs; |
| | |
*/ | | */ |
| | |
*pixmaps = (Pixmap *) malloc(sizeof(Pixmap *) * nrofpixmaps); | | *pixmaps = (Pixmap *) malloc(sizeof(Pixmap *) * nrofpixmaps); |
if (type==Dm_Pixmap) | | if (type==Dm_Pixmap || type==Dm_Png) |
*masks = (Pixmap *) malloc(sizeof(Pixmap *) * nrofpixmaps); | | *masks = (Pixmap *) malloc(sizeof(Pixmap *) * nrofpixmaps); |
| | |
for (i=0; i < nrofpixmaps; i++) | | for (i=0; i < nrofpixmaps; i++) |
| | |
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) |
| | sprintf(filename,"%s/crossfire.png",settings.datadir); |
| | |
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); |
| | |
i++; | | i++; |
if (!(i % 100)) LOG(llevDebug,"."); | | if (!(i % 100)) LOG(llevDebug,"."); |
| | |
| | if (type==Dm_Png) { |
| | #ifdef HAVE_LIBPNG |
| | unsigned long x,y; |
| | if (png_to_xpixmap(gdisp, root, databuf, len, |
| | &(*pixmaps)[num], &(*masks)[num], *cmap, &x, &y)) { |
| | |
| | LOG(llevError,"Error loading png file.\n"); |
| | } |
| | #endif |
| | } |
if (type==Dm_Pixmap) { | | if (type==Dm_Pixmap) { |
again: error=XpmCreatePixmapFromBuffer(gdisp, root, databuf, | | again: error=XpmCreatePixmapFromBuffer(gdisp, root, databuf, |
&(*pixmaps)[num], &(*masks)[num], &xpmatribs); | | &(*pixmaps)[num], &(*masks)[num], &xpmatribs); |
| | |
} | | } |
LOG(llevDebug,"done.\n"); | | LOG(llevDebug,"done.\n"); |
return use_private_cmap; | | return use_private_cmap; |
#else | | |
return 0; /* Prevents some warning messages */ | | return 0; /* Prevents some warning messages */ |
#endif | | |
} | | } |
| | |
/* This frees all the pixmaps. This not only makes for better code, | | /* This frees all the pixmaps. This not only makes for better code, |
| | |
} | | } |
return iscolor; | | return iscolor; |
} | | } |
| | |
| | |