home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / gnu / lucid / xpm-3.2a / XpmCrIFData.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-08-16  |  1.7 KB  |  55 lines

  1. /* Copyright 1990,91 GROUPE BULL -- See license conditions in file COPYRIGHT */
  2. /*****************************************************************************\
  3. * XpmCrIFData.c:                                                              *
  4. *                                                                             *
  5. *  XPM library                                                                *
  6. *  Parse an Xpm array and create the image and possibly its mask              *
  7. *                                                                             *
  8. *  Developed by Arnaud Le Hors                                                *
  9. \*****************************************************************************/
  10.  
  11. #include "xpmP.h"
  12.  
  13. int
  14. XpmCreateImageFromData(display, data, image_return,
  15.                shapeimage_return, attributes)
  16.     Display *display;
  17.     char **data;
  18.     XImage **image_return;
  19.     XImage **shapeimage_return;
  20.     XpmAttributes *attributes;
  21. {
  22.     xpmData mdata;
  23.     int ErrorStatus;
  24.     xpmInternAttrib attrib;
  25.  
  26.     /*
  27.      * initialize return values 
  28.      */
  29.     if (image_return)
  30.     *image_return = NULL;
  31.     if (shapeimage_return)
  32.     *shapeimage_return = NULL;
  33.  
  34.     if ((ErrorStatus = xpmOpenArray(data, &mdata)) != XpmSuccess)
  35.     return (ErrorStatus);
  36.  
  37.     xpmInitInternAttrib(&attrib);
  38.  
  39.     ErrorStatus = xpmParseData(&mdata, &attrib, attributes);
  40.  
  41.     if (ErrorStatus == XpmSuccess)
  42.     ErrorStatus = xpmCreateImage(display, &attrib, image_return,
  43.                      shapeimage_return, attributes);
  44.  
  45.     if (ErrorStatus >= 0)
  46.     xpmSetAttributes(&attrib, attributes);
  47.     else if (attributes)
  48.     XpmFreeAttributes(attributes);
  49.  
  50.     xpmFreeInternAttrib(&attrib);
  51.     XpmDataClose(&mdata);
  52.  
  53.     return (ErrorStatus);
  54. }
  55.