home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / X / mit / lib / Xmu / CrPixFBit.c < prev    next >
Encoding:
C/C++ Source or Header  |  1990-12-19  |  2.3 KB  |  67 lines

  1. /*
  2.  * $XConsortium: CrPixFBit.c,v 1.3 90/12/19 18:58:49 converse Exp $
  3.  *
  4.  * Copyright 1988 Massachusetts Institute of Technology
  5.  *
  6.  * Permission to use, copy, modify, distribute, and sell this software and its
  7.  * documentation for any purpose is hereby granted without fee, provided that
  8.  * the above copyright notice appear in all copies and that both that
  9.  * copyright notice and this permission notice appear in supporting
  10.  * documentation, and that the name of M.I.T. not be used in advertising or
  11.  * publicity pertaining to distribution of the software without specific,
  12.  * written prior permission.  M.I.T. makes no representations about the
  13.  * suitability of this software for any purpose.  It is provided "as is"
  14.  * without express or implied warranty.
  15.  *
  16.  * M.I.T. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
  17.  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL M.I.T.
  18.  * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  19.  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
  20.  * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
  21.  * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  22.  *
  23.  * This file contains miscellaneous utility routines and is not part of the
  24.  * Xlib standard.
  25.  *
  26.  * Public entry points:
  27.  *
  28.  *     XmuCreatePixmapFromBitmap    make a pixmap from a bitmap
  29.  */
  30.  
  31. #include <X11/Xos.h>
  32. #include <X11/Xlib.h>
  33.  
  34. Pixmap XmuCreatePixmapFromBitmap (dpy, d, bitmap, width, height, depth,
  35.                   fore, back)
  36.     Display *dpy;            /* connection to X server */
  37.     Drawable d;                /* drawable indicating screen */
  38.     Pixmap bitmap;            /* single plane pixmap */
  39.     unsigned int width, height;        /* dimensions of bitmap and pixmap */
  40.     unsigned int depth;            /* depth of pixmap to create */
  41.     unsigned long fore, back;        /* colors to use */
  42. {
  43.     Pixmap pixmap;
  44.  
  45.     pixmap = XCreatePixmap (dpy, d, width, height, depth);
  46.     if (pixmap != None) {
  47.     GC gc;
  48.     XGCValues xgcv;
  49.  
  50.     xgcv.foreground = fore;
  51.     xgcv.background = back;
  52.     xgcv.graphics_exposures = False;
  53.  
  54.     gc = XCreateGC (dpy, d,
  55.             (GCForeground | GCBackground | GCGraphicsExposures),
  56.             &xgcv);
  57.     if (gc) {
  58.         XCopyPlane (dpy, bitmap, pixmap, gc, 0, 0, width, height, 0, 0, 1);
  59.         XFreeGC (dpy, gc);
  60.     } else {
  61.         XFreePixmap (dpy, pixmap);
  62.         pixmap = None;
  63.     }
  64.     }
  65.     return pixmap;
  66. }
  67.