00001 /* $Xorg: CrPixFBit.c,v 1.4 2001/02/09 02:03:51 xorgcvs Exp $ */ 00002 00003 /* 00004 00005 Copyright 1988, 1998 The Open Group 00006 00007 Permission to use, copy, modify, distribute, and sell this software and its 00008 documentation for any purpose is hereby granted without fee, provided that 00009 the above copyright notice appear in all copies and that both that 00010 copyright notice and this permission notice appear in supporting 00011 documentation. 00012 00013 The above copyright notice and this permission notice shall be included in 00014 all copies or substantial portions of the Software. 00015 00016 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 00017 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 00018 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 00019 OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 00020 AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 00021 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 00022 00023 Except as contained in this notice, the name of The Open Group shall not be 00024 used in advertising or otherwise to promote the sale, use or other dealings 00025 in this Software without prior written authorization from The Open Group. 00026 00027 */ 00028 /* $XFree86: xc/lib/Xmu/CrPixFBit.c,v 1.6 2001/01/17 19:42:53 dawes Exp $ */ 00029 00030 /* 00031 * This file contains miscellaneous utility routines and is not part of the 00032 * Xlib standard. 00033 */ 00034 00035 /* 00036 * Public entry points: 00037 * 00038 * XmuCreatePixmapFromBitmap make a pixmap from a bitmap 00039 */ 00040 00041 #include <X11/Xos.h> 00042 #include <X11/Xlib.h> 00043 #include <X11/Xmu/Drawing.h> 00044 00045 Pixmap 00046 XmuCreatePixmapFromBitmap(Display *dpy, Drawable d, Pixmap bitmap, 00047 unsigned int width, unsigned int height, 00048 unsigned int depth, 00049 unsigned long fore, unsigned long back) 00050 /* 00051 * dpy - connection to X server 00052 * d - drawable indicating screen 00053 * bitmap - single plane pixmap 00054 * width, height - dimensions of bitmap and pixmap 00055 * depth - depth of pixmap to create 00056 * fore, back - colors to use 00057 */ 00058 { 00059 Pixmap pixmap; 00060 00061 pixmap = XCreatePixmap (dpy, d, width, height, depth); 00062 if (pixmap != None) { 00063 GC gc; 00064 XGCValues xgcv; 00065 00066 xgcv.foreground = fore; 00067 xgcv.background = back; 00068 xgcv.graphics_exposures = False; 00069 00070 gc = XCreateGC (dpy, d, 00071 (GCForeground | GCBackground | GCGraphicsExposures), 00072 &xgcv); 00073 if (gc) { 00074 XCopyPlane (dpy, bitmap, pixmap, gc, 0, 0, width, height, 0, 0, 1); 00075 XFreeGC (dpy, gc); 00076 } else { 00077 XFreePixmap (dpy, pixmap); 00078 pixmap = None; 00079 } 00080 } 00081 return pixmap; 00082 }
1.5.1