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.8.3 2007/06/29 03:20:58 das 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 38Pixmap 39XCreateBitmapFromData(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 = XCreateImage(display, NULL, 1, XYBitmap, 0, (char*) data, width, 56 height, 8, (width + 7) / 8); 57 ximage->bitmap_bit_order = LSBFirst; 58 _XInitImageFuncPtrs(ximage); 59 TkPutImage(NULL, 0, display, pix, gc, ximage, 0, 0, 0, 0, width, height); 60 ximage->data = NULL; 61 XDestroyImage(ximage); 62 XFreeGC(display, gc); 63 return pix; 64} 65