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