1 /*
2 * Copyright (C) 1989-95 GROUPE BULL
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a copy
5 * of this software and associated documentation files (the "Software"), to
6 * deal in the Software without restriction, including without limitation the
7 * rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * GROUPE BULL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
18 * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
19 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20 *
21 * Except as contained in this notice, the name of GROUPE BULL shall not be used
22 * in advertising or otherwise to promote the sale, use or other dealings in
23 * this Software without prior written authorization from GROUPE BULL.
24 */
25
26 /*****************************************************************************\
27 * RdFToP.c: *
28 * *
29 * XPM library *
30 * Parse an XPM file and create the pixmap and possibly its mask *
31 * *
32 * Developed by Arnaud Le Hors *
33 \*****************************************************************************/
34
35 #include "xpmP.h"
36
37 int
XpmReadFileToPixmap(display,d,filename,pixmap_return,shapemask_return,attributes)38 XpmReadFileToPixmap(display, d, filename, pixmap_return,
39 shapemask_return, attributes)
40 Display *display;
41 Drawable d;
42 char *filename;
43 Pixmap *pixmap_return;
44 Pixmap *shapemask_return;
45 XpmAttributes *attributes;
46 {
47 XImage *ximage, *shapeimage;
48 int ErrorStatus;
49
50 /* initialize return values */
51 if (pixmap_return)
52 *pixmap_return = 0;
53 if (shapemask_return)
54 *shapemask_return = 0;
55
56 /* create the images */
57 ErrorStatus = XpmReadFileToImage(display, filename,
58 (pixmap_return ? &ximage : NULL),
59 (shapemask_return ? &shapeimage : NULL),
60 attributes);
61
62 if (ErrorStatus < 0) /* fatal error */
63 return (ErrorStatus);
64
65 /* create the pixmaps and destroy images */
66 if (pixmap_return && ximage)
67 {
68 xpmCreatePixmapFromImage(display, d, ximage, pixmap_return);
69 XDestroyImage(ximage);
70 }
71 if (shapemask_return && shapeimage)
72 {
73 xpmCreatePixmapFromImage(display, d, shapeimage, shapemask_return);
74 XDestroyImage(shapeimage);
75 }
76 return (ErrorStatus);
77 }
78