Debian Codegraph @

src/CrPFrI.c

raw
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, and/or
8 * sell copies of the Software, and to permit persons to whom the Software is
9 * 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 IN
18 * 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
22 * used in advertising or otherwise to promote the sale, use or other dealings
23 * in this Software without prior written authorization from GROUPE BULL.
24 */
25
26 /*****************************************************************************\
27 * CrPFrI.c: *
28 * *
29 * XPM library *
30 * Create the Pixmap related to the given XImage. *
31 * *
32 * Developed by Arnaud Le Hors *
33 \*****************************************************************************/
34
35 #ifdef HAVE_CONFIG_H
36 #include <config.h>
37 #endif
38 #include "XpmI.h"
39 #include <stdint.h>
40
41 int
42 xpmCreatePixmapFromImage(
43 Display *display,
44 Drawable d,
45 XImage *ximage,
46 Pixmap *pixmap_return)
47 {
48 GC gc;
49 XGCValues values;
50
51 /* X Pixmaps are limited to unsigned 16-bit height/width */
52 if ((ximage->width > UINT16_MAX) || (ximage->height > UINT16_MAX)) {
53 return XpmNoMemory;
54 }
55
56 *pixmap_return = XCreatePixmap(display, d, ximage->width,
57 ximage->height, ximage->depth);
58 /* set fg and bg in case we have an XYBitmap */
59 values.foreground = 1;
60 values.background = 0;
61 gc = XCreateGC(display, *pixmap_return,
62 GCForeground | GCBackground, &values);
63
64 XPutImage(display, *pixmap_return, gc, ximage, 0, 0, 0, 0,
65 ximage->width, ximage->height);
66
67 XFreeGC(display, gc);
68
69 return XpmSuccess;
70 }