1 |
/* $Header: /cvsroot/esrg/sfesrg/esrgpcpj/shared/tk_base/ximage.c,v 1.1.1.1 2001/06/13 05:15:44 dtashley Exp $ */
|
2 |
|
3 |
/*
|
4 |
* ximage.c --
|
5 |
*
|
6 |
* X bitmap and image routines.
|
7 |
*
|
8 |
* Copyright (c) 1995 Sun Microsystems, Inc.
|
9 |
*
|
10 |
* See the file "license.terms" for information on usage and redistribution
|
11 |
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
12 |
*
|
13 |
* RCS: @(#) $Id: ximage.c,v 1.1.1.1 2001/06/13 05:15:44 dtashley Exp $
|
14 |
*/
|
15 |
|
16 |
#include "tkInt.h"
|
17 |
|
18 |
|
19 |
/*
|
20 |
*----------------------------------------------------------------------
|
21 |
*
|
22 |
* XCreateBitmapFromData --
|
23 |
*
|
24 |
* Construct a single plane pixmap from bitmap data.
|
25 |
*
|
26 |
* NOTE: This procedure has the correct behavior on Windows and
|
27 |
* the Macintosh, but not on UNIX. This is probably because the
|
28 |
* emulation for XPutImage on those platforms compensates for whatever
|
29 |
* is wrong here :-)
|
30 |
*
|
31 |
* Results:
|
32 |
* Returns a new Pixmap.
|
33 |
*
|
34 |
* Side effects:
|
35 |
* Allocates a new bitmap and drawable.
|
36 |
*
|
37 |
*----------------------------------------------------------------------
|
38 |
*/
|
39 |
|
40 |
Pixmap
|
41 |
XCreateBitmapFromData(display, d, data, width, height)
|
42 |
Display* display;
|
43 |
Drawable d;
|
44 |
_Xconst char* data;
|
45 |
unsigned int width;
|
46 |
unsigned int height;
|
47 |
{
|
48 |
XImage ximage;
|
49 |
GC gc;
|
50 |
Pixmap pix;
|
51 |
|
52 |
pix = Tk_GetPixmap(display, d, width, height, 1);
|
53 |
gc = XCreateGC(display, pix, 0, NULL);
|
54 |
if (gc == NULL) {
|
55 |
return None;
|
56 |
}
|
57 |
ximage.height = height;
|
58 |
ximage.width = width;
|
59 |
ximage.depth = 1;
|
60 |
ximage.bits_per_pixel = 1;
|
61 |
ximage.xoffset = 0;
|
62 |
ximage.format = XYBitmap;
|
63 |
ximage.data = (char *)data;
|
64 |
ximage.byte_order = LSBFirst;
|
65 |
ximage.bitmap_unit = 8;
|
66 |
ximage.bitmap_bit_order = LSBFirst;
|
67 |
ximage.bitmap_pad = 8;
|
68 |
ximage.bytes_per_line = (width+7)/8;
|
69 |
|
70 |
TkPutImage(NULL, 0, display, pix, gc, &ximage, 0, 0, 0, 0, width, height);
|
71 |
XFreeGC(display, gc);
|
72 |
return pix;
|
73 |
}
|
74 |
|
75 |
|
76 |
/* $History: ximage.c $
|
77 |
*
|
78 |
* ***************** Version 1 *****************
|
79 |
* User: Dtashley Date: 1/02/01 Time: 3:21a
|
80 |
* Created in $/IjuScripter, IjuConsole/Source/Tk Base
|
81 |
* Initial check-in.
|
82 |
*/
|
83 |
|
84 |
/* End of XIMAGE.C */ |