Museum

Home

Lab Overview

Retrotechnology Articles

⇒ Online Manual

Media Vault

Software Library

Restoration Projects

Artifacts Sought

NAME

XCreatePixmapFromBitmapData − create a pixmap with depth from bitmap data. 

Synopsis

Pixmap XCreatePixmapFromBitmapData(display, drawable, data,

width, height, fg, bg, depth)
     Display *display;
     Drawable drawable;
     char *data;
     unsigned int width, height;
     unsigned long fg, bg;
     unsigned int depth;

Arguments

displaySpecifies a connection to an Display structure, returned from XOpenDisplay(). 

drawableSpecifies a drawable ID which indicates which screen the pixmap is to be used on. 

dataSpecifies the data in bitmap format. 

width

heightSpecify the width and height in pixels of the pixmap to create. 

fg

bgSpecify the foreground and background pixel values to use. 

depthSpecifies the depth of the pixmap.  Must be valid on the screen specified by drawable. 

Description

XCreatePixmapFromBitmapData() creates a pixmap of the given depth using bitmap data and foreground and background pixel values.  The following format for the data is assigned, where the variables are members of the XImage structure described in Volume One, Chapter 6, Drawing Graphics and Text:

format=XYPixmap
bit_order=LSBFirst
byte_order=LSBFirst
bitmap_unit=8
bitmap_pad=8
xoffset=0
no extra bytes per line

XCreatePixmapFromBitmapData() creates an image from the data and uses XPutImage() to place the data into the pixmap.  For example:

#define gray_width 16
#define gray_height 16
#define gray_x_hot 8
#define gray_y_hot 8
static char gray_bits[] = {
    0xf8, 0x1f, 0xe3, 0xc7, 0xcf, 0xf3, 0x9f, 0xf9, 0xbf,
    0xfd, 0x33, 0xcc, 0x7f, 0xfe, 0x7f, 0xfe, 0x7e, 0x7e,
    0x7f, 0xfe, 0x37, 0xec, 0xbb, 0xdd, 0x9c, 0x39, 0xcf,
    0xf3, 0xe3, 0xc7, 0xf8, 0x1f};
unsigned long foreground, background;
unsigned int depth;
 /* open display, determine colors and depth */
 Pixmap XCreatePixmapFromBitmapData()(display, window, gray_bits,
gray_width, gray_height, foreground, background, depth);

If you want to use data of a different format, it is straightforward to write a routine that does this yourself, using images.  Pixmaps should be considered a precious resource, since many servers have limits on the amount of off-screen memory available.  If you are creating a pixmap for use in XCreatePixmapCursor(), specify depth=1, fg=1, and bg=0. 

Errors

BadAlloc

BadDrawable

BadGC

BadValuedepth is not a valid depth on the screen specified by drawable. 

See Also

XCreateBitmapFromData(), XCreateFontCursor(), XCreatePixmap(), XCreatePixmapCursor(), XDefineCursor(), XFreeCursor(), XFreePixmap(), XListPixmapFormats(), XQueryBestCursor(), XQueryBestSize(), XReadBitmapFile(), XRecolorCursor(), XUndefineCursor(). 

Copyright O’Reilly & Assoc.  —  

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026