XReadBitmapFile, XReadBitmapFileData, XWriteBitmapFile, XCreatePixmapFromBitmapData, XCreateBitmapFromData − manipulate bitmaps


int XReadBitmapFile(Display *display, Drawable d, char *filename, unsigned int *width_return, unsigned int *height_return, Pixmap *bitmap_return, int *x_hot_return, int *y_hot_return);

int XReadBitmapFileData(char *filename, unsigned int *width_return, unsigned int *height_return, unsigned char *data_return, int *x_hot_return, int *y_hot_return);

int XWriteBitmapFile(Display *display, char *filename, Pixmap bitmap, unsigned int width, unsigned int height, int x_hot, int y_hot);

Pixmap XCreatePixmapFromBitmapData(Display *display, Drawable d, char *data, unsigned int width, unsigned int height, unsigned long fg, unsigned long bg, unsigned int depth);

Pixmap XCreateBitmapFromData(Display *display, Drawable d, char *data, unsigned int width, unsigned int height);



Specifies the bitmap.


Returns the bitmap that is created.


Specifies the drawable that indicates the screen.


Specifies the data in bitmap format.


Specifies the location of the bitmap data.


Returns the bitmap data.


Specifies the depth of the pixmap.


Specifies the connection to the X server.



Specify the foreground and background pixel values to use.


Specifies the file name to use. The format of the file name is operating-system dependent.



Specify the width and height.


Return the width and height values of the read in bitmap file.



Specify where to place the hotspot coordinates (or −1,−1 if none are present) in the file.


Return the hotspot coordinates.


The XReadBitmapFile function reads in a file containing a bitmap. The file is parsed in the encoding of the current locale. The ability to read other than the standard format is implementation-dependent. If the file cannot be opened, XReadBitmapFile returns BitmapOpenFailed. If the file can be opened but does not contain valid bitmap data, it returns BitmapFileInvalid. If insufficient working storage is allocated, it returns BitmapNoMemory. If the file is readable and valid, it returns BitmapSuccess.

XReadBitmapFile 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 appropriate 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 XFreePixmap when finished. If name_x_hot and name_y_hot exist, XReadBitmapFile returns them to x_hot_return and y_hot_return; otherwise, it returns −1,−1.

XReadBitmapFile can generate BadAlloc and BadDrawable errors.

The XReadBitmapFileData function reads in a file containing a bitmap, in the same manner as XReadBitmapFile, but returns the data directly rather than creating a pixmap in the server. The bitmap data is returned in data_return; the client must free this storage when finished with it by calling XFree. The status and other return values are the same as for XReadBitmapFile.

The XWriteBitmapFile function writes a bitmap out to a file in the X Version 11 format. The name used in the output file is derived from the file name by deleting the directory prefix. The file is written in the encoding of the current locale. If the file cannot be opened for writing, it returns BitmapOpenFailed. If insufficient memory is allocated, XWriteBitmapFile returns BitmapNoMemory; otherwise, on no error, it returns BitmapSuccess. If x_hot and y_hot are not −1, −1, XWriteBitmapFile writes them out as the hotspot coordinates for the bitmap.

XWriteBitmapFile can generate BadDrawable and BadMatch errors.

The XCreatePixmapFromBitmapData function creates a pixmap of the given depth and then does a bitmap-format XPutImage of the data into it. The depth must be supported by the screen of the specified drawable, or a BadMatch error results.

XCreatePixmapFromBitmapData can generate BadAlloc and BadMatch errors.

The XCreateBitmapFromData function allows you to include in your C program (using #include) a bitmap file that was written out by XWriteBitmapFile (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, XCreateBitmapFromData returns None. It is your responsibility to free the bitmap using XFreePixmap when finished.

XCreateBitmapFromData can generate a BadAlloc error.



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 InputOnly window is used as a Drawable.


XCreatePixmap(3), XPutImage(3)
Xlib − C Language X Interface

More Linux Commands

pdfimages(1) - Portable Document Format (PDF) image extracto
Pdfimages saves images from a Portable Document Format (PDF) file as Portable Pixmap (PPM), Portable Bitmap (PBM), Portable Network Graphics (PNG), Tagged Image

xdr_u_char(3) - library routines for external data represent
These routines allow C programmers to describe arbitrary data structures in a machine-independent fashion. Data for remote procedure calls are transmitted using

clntudp_bufcreate(3) - library routines for remote procedure
These routines allow C programs to make procedure calls on other machines across the network. First, the client calls a procedure to send a data packet to the s

SDL_CDName(3) - Returns a human-readable, system-dependent i
Returns a human-readable, system-dependent identifier for the CD-ROM. drive is the index of the drive. Drive indices start to 0 and end at SDL_CDNumDrives()-1.

mysql_secure_installation(1) - improve MySQL installation se
This program enables you to improve the security of your MySQL installation in the following ways: * You can set a password for root accounts. * You can remove

zcmp(1) - compare compressed files - Linux manual page......
Zcmp and zdiff are used to invoke the cmp or the diff program on files compressed via gzip. All options specified are passed directly to cmp or diff. If only fi

gnutls_pkcs12_import(3) - API function - Linux manual page
This function will convert the given DER or PEM encoded PKCS12 to the native gnutls_pkcs12_t format. The output will be stored in pkcs12. If the PKCS12 is PEM e

auparse_get_field_name(3) - get current field's name........
auparse_get_field_name allows access to the current field name of the current record in the current event. RETURN VALUE Returns NULL if an error occurs; otherwi

fgetpwent_r(3) - get passwd file entry reentrantly (ManPage)
The functions getpwent_r() and fgetpwent_r() are the reentrant versions of getpwent(3) and fgetpwent(3). The former reads the next passwd entry from the stream

pammasksharpen(1) - Sharpen an image via an unsharp mask....
This program is part of Netpbm(1) pammasksharpen reads a Netpbm image as input and produces a sharpened version of it, in the same format, as output. It does th

pcre32_maketables(3) Perl-compatible regular expressions....
This function builds a set of character tables for character values less than 256. These can be passed to pcre[16|32]_compile() to override PCREs internal, buil

getmaxy(3ncurses) - get curses cursor and window coordinates
The getbegy and getbegx functions return the same data as getbegyx. The getcury and getcurx functions return the same data as getyx. The getmaxy and getmaxx fun

We can't live, work or learn in freedom unless the software we use is free.