|
|
1.1 ! root 1: #include "copyright.h" ! 2: ! 3: ! 4: #include "Xlib.h" ! 5: ! 6: /* ! 7: * MakeBitmap: Routine to make a pixmap from user supplied data. ! 8: * D is the window the pixmap will be used in (i.e, where ! 9: * to get depth from). Data is a pointer to the bit data, and ! 10: * width & height give the size in bits of the pixmap. ! 11: * ! 12: * The following format is assumed for data: ! 13: * ! 14: * format=XYPixmap ! 15: * bit_order=LSBFirst ! 16: * byte_order=LSBFirst ! 17: * padding=8 ! 18: * bitmap_unit=8 ! 19: * xoffset=0 ! 20: * no extra bytes per line ! 21: */ ! 22: Pixmap XCreateBitmapFromData(display, d, data, width, height) ! 23: Display *display; ! 24: Drawable d; ! 25: char *data; ! 26: int width, height; ! 27: { ! 28: XImage ximage; ! 29: GC gc; ! 30: XGCValues gcv; ! 31: Pixmap pix; ! 32: ! 33: pix = XCreatePixmap(display, d, width, height, 1); ! 34: if (!pix) ! 35: return(0); ! 36: gcv.foreground = 1; ! 37: gcv.background = 0; ! 38: gc = XCreateGC(display, pix, GCForeground|GCBackground, &gcv); ! 39: ximage.height = height; ! 40: ximage.width = width; ! 41: ximage.depth = 1; ! 42: ximage.xoffset = 0; ! 43: ximage.format = XYBitmap; ! 44: ximage.data = data; ! 45: ximage.byte_order = LSBFirst; ! 46: ximage.bitmap_unit = 8; ! 47: ximage.bitmap_bit_order = LSBFirst; ! 48: ximage.bitmap_pad = 8; ! 49: ximage.bytes_per_line = (width+7)/8; ! 50: ! 51: XPutImage(display, pix, gc, &ximage, 0, 0, 0, 0, width, height); ! 52: XFreeGC(display, gc); ! 53: return(pix); ! 54: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.