Debian Codegraph @

pTk/mTk/xlib/ximage.c

raw symbols SCIP
1 /*
2 * ximage.c --
3 *
4 * X bitmap and image routines.
5 *
6 * Copyright (c) 1995 Sun Microsystems, Inc.
7 *
8 * See the file "license.terms" for information on usage and redistribution
9 * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
10 *
11 * RCS: @(#) $Id: ximage.c,v 1.4 2000/07/06 03:17:45 mo Exp $
12 */
13
14 #include "tkInt.h"
15
16
17 /*
18 *----------------------------------------------------------------------
19 *
20 * XCreateBitmapFromData --
21 *
22 * Construct a single plane pixmap from bitmap data.
23 *
24 * NOTE: This procedure has the correct behavior on Windows and
25 * the Macintosh, but not on UNIX. This is probably because the
26 * emulation for XPutImage on those platforms compensates for whatever
27 * is wrong here :-)
28 *
29 * Results:
30 * Returns a new Pixmap.
31 *
32 * Side effects:
33 * Allocates a new bitmap and drawable.
34 *
35 *----------------------------------------------------------------------
36 */
37
38 Pixmap
39 XCreateBitmapFromData(display, d, data, width, height)
40 Display* display;
41 Drawable d;
42 _Xconst char* data;
43 unsigned int width;
44 unsigned int height;
45 {
46 XImage ximage;
47 GC gc;
48 Pixmap pix;
49
50 pix = Tk_GetPixmap(display, d, (int) width, (int) height, 1);
51 gc = XCreateGC(display, pix, 0, NULL);
52 if (gc == NULL) {
53 return None;
54 }
55 ximage.height = height;
56 ximage.width = width;
57 ximage.depth = 1;
58 ximage.bits_per_pixel = 1;
59 ximage.xoffset = 0;
60 ximage.format = XYBitmap;
61 ximage.data = (char *)data;
62 ximage.byte_order = LSBFirst;
63 ximage.bitmap_unit = 8;
64 ximage.bitmap_bit_order = LSBFirst;
65 ximage.bitmap_pad = 8;
66 ximage.bytes_per_line = (width+7)/8;
67
68 TkPutImage(NULL, 0, display, pix, gc, &ximage, 0, 0, 0, 0, width, height);
69 XFreeGC(display, gc);
70 return pix;
71 }