home *** CD-ROM | disk | FTP | other *** search
/ ftp.cs.arizona.edu / ftp.cs.arizona.edu.tar / ftp.cs.arizona.edu / icon / historic / v941.tgz / icon.v941src.tar / icon.v941src / src / xpm / XpmWrFFrP.c < prev   
C/C++ Source or Header  |  2000-07-29  |  2KB  |  76 lines

  1. /* Copyright 1990-92 GROUPE BULL -- See license conditions in file COPYRIGHT */
  2. /*****************************************************************************\
  3. * XpmWrFFrP.c:                                                                *
  4. *                                                                             *
  5. *  XPM library                                                                *
  6. *  Write a pixmap and possibly its mask to an XPM file                        *
  7. *                                                                             *
  8. *  Developed by Arnaud Le Hors                                                *
  9. \*****************************************************************************/
  10.  
  11. #include "xpmP.h"
  12. #ifdef VMS
  13. #include "sys$library:string.h"
  14. #else
  15. #if defined(SYSV) || defined(SVR4)
  16. #include <string.h>
  17. #else
  18. #include <strings.h>
  19. #endif
  20. #endif
  21.  
  22. int
  23. XpmWriteFileFromPixmap(display, filename, pixmap, shapemask, attributes)
  24.     Display *display;
  25.     char *filename;
  26.     Pixmap pixmap;
  27.     Pixmap shapemask;
  28.     XpmAttributes *attributes;
  29. {
  30.     XImage *image = NULL;
  31.     XImage *shapeimage = NULL;
  32.     unsigned int width = 0;
  33.     unsigned int height = 0;
  34.     int ErrorStatus;
  35.     unsigned int dum;
  36.     int dummy;
  37.     Window win;
  38.  
  39.     /*
  40.      * get geometry 
  41.      */
  42.     if (attributes && attributes->valuemask & XpmSize) {
  43.     width = attributes->width;
  44.     height = attributes->height;
  45.     } else {
  46.     if (pixmap)
  47.         XGetGeometry(display, pixmap, &win, &dummy, &dummy,
  48.              &width, &height, &dum, &dum);
  49.     else if (shapemask)
  50.         XGetGeometry(display, shapemask, &win, &dummy, &dummy,
  51.              &width, &height, &dum, &dum);
  52.     }
  53.  
  54.     /*
  55.      * get the images 
  56.      */
  57.     if (pixmap)
  58.     image = XGetImage(display, pixmap, 0, 0, width, height,
  59.               AllPlanes, ZPixmap);
  60.     if (shapemask)
  61.     shapeimage = XGetImage(display, shapemask, 0, 0, width, height,
  62.                    AllPlanes, ZPixmap);
  63.  
  64.     /*
  65.      * write them out 
  66.      */
  67.     ErrorStatus = XpmWriteFileFromImage(display, filename, image, shapeimage,
  68.                     attributes);
  69.     if (image)
  70.     XDestroyImage(image);
  71.     if (shapeimage)
  72.     XDestroyImage(shapeimage);
  73.  
  74.     return (ErrorStatus);
  75. }
  76.