xcreatepixc(3) [hpux man page]
XCreatePixmapFromBitmapData() XCreatePixmapFromBitmapData() 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 display Specifies a connection to an Display structure, returned from XOpenDisplay(). drawable Specifies a drawable ID which indicates which screen the pixmap is to be used on. data Specifies the data in bitmap format. width Specify the width and height in pixels of the pixmap to create. height fg Specify the foreground and background pixel values to use. bg depth Specifies the depth of the pixmap. Must be valid on the screen specified by drawable. Returns The created Pixmap. 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 BadValue depth is not a valid depth on the screen specified by drawable. See Also XCreateBitmapFromData(), XCreateFontCursor(), XCreatePixmap(), XCreatePixmapCursor(), XDefineCursor(), XFreeCursor(), XFreePixmap(), XList- PixmapFormats(), XQueryBestCursor(), XQueryBestSize(), XReadBitmapFile(), XRecolorCursor(), XUndefineCursor(). Xlib - Pixmaps and Bitmaps XCreatePixmapFromBitmapData()
Check Out this Related Man Page
XReadBitmapFile(3X11) MIT X11R4 XReadBitmapFile(3X11) Name XReadBitmapFile, XWriteBitmapFile, XCreatePixmapFromBitmapData, XCreateBitmapFromData - manipulate bitmaps Syntax int XReadBitmapFile(display, d, filename, width_return, height_return, bitmap_return, x_hot_return, y_hot_return) Display *display; Drawable d; char *filename; unsigned int *width_return, *height_return; Pixmap *bitmap_return; int *x_hot_return, *y_hot_return; int XWriteBitmapFile(display, filename, bitmap, width, height, x_hot, y_hot) Display *display; char *filename; Pixmap bitmap; unsigned int width, height; int x_hot, y_hot; Pixmap XCreatePixmapFromBitmapData(display, d, data, width, height, fg, bg, depth) Display *display; Drawable d; char *data; unsigned int width, height; unsigned long fg, bg; unsigned int depth; Pixmap XCreateBitmapFromData(display, d, data, width, height) Display *display; Drawable d; char *data; unsigned int width, height; Arguments bitmap Specifies the bitmap. bitmap_return Returns the bitmap that is created. d Specifies the drawable that indicates the screen. data Specifies the data in bitmap format. data Specifies the location of the bitmap data. depth Specifies the depth of the pixmap. display Specifies the connection to the X server. fg bg Specify the foreground and background pixel values to use. filename Specifies the file name to use. The format of the file name is operating-system dependent. width height Specify the width and height. width_return height_return Return the width and height values of the read in bitmap file. x_hot y_hot Specify where to place the hotspot coordinates (or -1,-1 if none are present) in the file. x_hot_return y_hot_return Return the hotspot coordinates. Description The function reads in a file containing a bitmap. The ability to read other than the standard format is implementation dependent. If the file cannot be opened, returns If the file can be opened but does not contain valid bitmap data, it returns If insufficient working storage is allocated, it returns If the file is readable and valid, it returns returns the bitmap's height and width, as read from the file, to width_return and height_return. It then creates a pixmap of the appropri- ate size, reads the bitmap data from the file into the pixmap, and assigns the pixmap to the caller's variable bitmap. The caller must free the bitmap using when finished. If name_x_hot and name_y_hot exist, returns them to x_hot_return and y_hot_return; otherwise, it returns -1,-1. can generate and errors. The function writes a bitmap out to a file in the X version 11 format. If the file cannot be opened for writing, it returns If insuffi- cient memory is allocated, returns otherwise, on no error, it returns If x_hot and y_hot are not -1, -1, writes them out as the hotspot coordinates for the bitmap. can generate and errors. The function creates a pixmap of the given depth and then does a bitmap-format of the data into it. The depth must be supported by the screen of the specified drawable, or a error results. can generate and errors. The function allows you to include in your C program (using #include) a bitmap file that was written out by (X version 11 format only) without reading in the bitmap file. The following example creates a gray bitmap: #include "gray.bitmap" Pixmap bitmap; bitmap = XCreateBitmapFromData(display, window, gray_bits, gray_width, gray_height); If insufficient working storage was allocated, returns It is your responsibility to free the bitmap using when finished. can generate a error. Diagnostics The server failed to allocate the requested resource or server memory. A value for a Drawable argument does not name a defined Window or Pixmap. An window is used as a Drawable. See Also XCreatePixmap(3X11), XPutImage(3X11) X Window System: The Complete Reference, Second Edition, Robert W. Scheifler and James Gettys XReadBitmapFile(3X11)