CrPixFBit.c revision 6c321187
1/* $Xorg: CrPixFBit.c,v 1.4 2001/02/09 02:03:51 xorgcvs Exp $ */ 2 3/* 4 5Copyright 1988, 1998 The Open Group 6 7Permission to use, copy, modify, distribute, and sell this software and its 8documentation for any purpose is hereby granted without fee, provided that 9the above copyright notice appear in all copies and that both that 10copyright notice and this permission notice appear in supporting 11documentation. 12 13The above copyright notice and this permission notice shall be included in 14all copies or substantial portions of the Software. 15 16THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 20AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 22 23Except as contained in this notice, the name of The Open Group shall not be 24used in advertising or otherwise to promote the sale, use or other dealings 25in this Software without prior written authorization from The Open Group. 26 27*/ 28/* $XFree86: xc/lib/Xmu/CrPixFBit.c,v 1.6 2001/01/17 19:42:53 dawes Exp $ */ 29 30/* 31 * This file contains miscellaneous utility routines and is not part of the 32 * Xlib standard. 33 */ 34 35/* 36 * Public entry points: 37 * 38 * XmuCreatePixmapFromBitmap make a pixmap from a bitmap 39 */ 40 41#ifdef HAVE_CONFIG_H 42#include <config.h> 43#endif 44#include <X11/Xos.h> 45#include <X11/Xlib.h> 46#include <X11/Xmu/Drawing.h> 47 48Pixmap 49XmuCreatePixmapFromBitmap(Display *dpy, Drawable d, Pixmap bitmap, 50 unsigned int width, unsigned int height, 51 unsigned int depth, 52 unsigned long fore, unsigned long back) 53 /* 54 * dpy - connection to X server 55 * d - drawable indicating screen 56 * bitmap - single plane pixmap 57 * width, height - dimensions of bitmap and pixmap 58 * depth - depth of pixmap to create 59 * fore, back - colors to use 60 */ 61{ 62 Pixmap pixmap; 63 64 pixmap = XCreatePixmap (dpy, d, width, height, depth); 65 if (pixmap != None) { 66 GC gc; 67 XGCValues xgcv; 68 69 xgcv.foreground = fore; 70 xgcv.background = back; 71 xgcv.graphics_exposures = False; 72 73 gc = XCreateGC (dpy, d, 74 (GCForeground | GCBackground | GCGraphicsExposures), 75 &xgcv); 76 if (gc) { 77 XCopyPlane (dpy, bitmap, pixmap, gc, 0, 0, width, height, 0, 0, 1); 78 XFreeGC (dpy, gc); 79 } else { 80 XFreePixmap (dpy, pixmap); 81 pixmap = None; 82 } 83 } 84 return pixmap; 85} 86