[comp.windows.x] missing entry point in X libs?

murthy@bifrost.cs.cornell.edu (Chet Murthy) (09/22/88)

There's an undefined reference for a function
XCreatePixmapFromBitmapData in libXaw
which I can't seem to find the code for.
(i.e. the reference is _in_ libXaw, and
there is no file which seems to contain such
a function.  Does anybody know what's wrong?

--chet--
 
	--chet--
	murthy@svax.cs.cornell.edu

jim@EXPO.LCS.MIT.EDU (Jim Fulton) (09/22/88)

> There's an undefined reference for a function
> XCreatePixmapFromBitmapData in libXaw

This function was added to Xlib in R2; see lib/X/XCrPFBData.c.

hkbirke@mit-amt (Hal Birkeland) (09/23/88)

In article <21240@cornell.UUCP> murthy@cs.cornell.edu (Chet Murthy) writes:
>There's an undefined reference for a function
>XCreatePixmapFromBitmapData in libXaw
>which I can't seem to find the code for.
>(i.e. the reference is _in_ libXaw, and
>there is no file which seems to contain such
>a function.  Does anybody know what's wrong?
>
>	--chet--
>	murthy@svax.cs.cornell.edu

yep. you are exactly right... this function is NOT implemented -- so
much for QC from X Consortium. It belongs in libX.a (the C library).

It is VERY easy to write, however. Basically you combine another
XCreate..  call that is extrmely similar function
(XCreateBitmapFromData) with about three lines of generated code.

Here it is... care of Daniel I. Applebaum, who actually wrote it. This has
been tested on IBM RTPCs, and MVII with Parallax. Not guaranteed to work
on anything though...

-- hal
hkbirke@media-lab.media.mit.edu
...!mit-amt!hkbirke

Now, if only:
	-- X11R3 exists, since someone optimized the "mi" code.
	-- HP Gator support will appear, since the PD server doesnt support it.



-----cut here ---
#include<X11/Xlib.h>

/*
 * XCreateBitmapFromData: Routine to make a pixmap of depth 1 from user supplied data.
 *             D is any drawable on the same screen that the pixmap will be used in.
 *             Data is a pointer to the bit data, and 
 *             width & height give the size in bits of the pixmap.
 *
 * The following format is assumed for data:
 *
 *    format=XYPixmap
 *    bit_order=LSBFirst
 *    byte_order=LSBFirst
 *    padding=8
 *    bitmap_unit=8
 *    xoffset=0
 *    no extra bytes per line
 */  
Pixmap XCreatePixmapFromBitmapData(display, d, data, width, height, fg, bg, depth)
     Display *display;
     Drawable d;
     char *data;
     unsigned int width, height;
     unsigned long fg, bg;
     unsigned int depth;
{
    XImage ximage;
    GC gc;
    XGCValues gcv;
    Pixmap pix;

    pix = XCreatePixmap(display, d, width, height, depth);
    if (!pix)
      return(0);
    gcv.foreground = fg;
    gcv.background = bg;
    gc = XCreateGC(display, pix, GCForeground|GCBackground, &gcv);
    ximage.height = height;
    ximage.width = width;
    ximage.depth = 1;
    ximage.xoffset = 0;
    ximage.format = XYBitmap;
    ximage.data = data;
    ximage.byte_order = LSBFirst;
    ximage.bitmap_unit = 8;
    ximage.bitmap_bit_order = LSBFirst;
    ximage.bitmap_pad = 8;
    ximage.bytes_per_line = (width+7)/8;

    XPutImage(display, pix, gc, &ximage, 0, 0, 0, 0, width, height);
    XFreeGC(display, gc);
    return(pix);
}