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 of 9 * this file, and for a DISCLAIMER OF ALL WARRANTIES. 10 * 11 * RCS: @(#) $Id$ 12 */ 13 14#include "tkInt.h" 15 16/* 17 *---------------------------------------------------------------------- 18 * 19 * XCreateBitmapFromData -- 20 * 21 * Construct a single plane pixmap from bitmap data. 22 * 23 * NOTE: This procedure has the correct behavior on Windows and the 24 * Macintosh, but not on UNIX. This is probably because the emulation for 25 * XPutImage on those platforms compensates for whatever is wrong here 26 * :-) 27 * 28 * Results: 29 * Returns a new Pixmap. 30 * 31 * Side effects: 32 * Allocates a new bitmap and drawable. 33 * 34 *---------------------------------------------------------------------- 35 */ 36 37Pixmap 38XCreateBitmapFromData( 39 Display *display, 40 Drawable d, 41 _Xconst char *data, 42 unsigned int width, 43 unsigned int height) 44{ 45 XImage *ximage; 46 GC gc; 47 Pixmap pix; 48 49 pix = Tk_GetPixmap(display, d, (int) width, (int) height, 1); 50 gc = XCreateGC(display, pix, 0, NULL); 51 if (gc == NULL) { 52 return None; 53 } 54 ximage = XCreateImage(display, NULL, 1, XYBitmap, 0, (char*) data, width, 55 height, 8, (width + 7) / 8); 56 ximage->bitmap_bit_order = LSBFirst; 57 _XInitImageFuncPtrs(ximage); 58 TkPutImage(NULL, 0, display, pix, gc, ximage, 0, 0, 0, 0, width, height); 59 ximage->data = NULL; 60 XDestroyImage(ximage); 61 XFreeGC(display, gc); 62 return pix; 63} 64 65/* 66 * Local Variables: 67 * mode: c 68 * c-basic-offset: 4 69 * fill-column: 78 70 * End: 71 */ 72