NAME

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

SYNTAX

int XReadBitmapFile(Display *_d_i_s_p_l_a_y, Drawable _d, char *_f_i_l_e_n_a_m_e, unsigned int *_w_i_d_t_h___r_e_t_u_r_n, unsigned int *_h_e_i_g_h_t___r_e_t_u_r_n, Pixmap *_b_i_t_m_a_p___r_e_t_u_r_n, int *_x___h_o_t___r_e_t_u_r_n, int *_y___h_o_t___r_e_t_u_r_n); int XReadBitmapFileData(char *_f_i_l_e_n_a_m_e, unsigned int *_w_i_d_t_h___r_e_t_u_r_n, unsigned int *_h_e_i_g_h_t___r_e_t_u_r_n, unsigned char *_d_a_t_a___r_e_t_u_r_n, int *_x___h_o_t___r_e_t_u_r_n, int *_y___h_o_t___r_e_t_u_r_n); int XWriteBitmapFile(Display *_d_i_s_p_l_a_y, char *_f_i_l_e_n_a_m_e, Pixmap _b_i_t_m_a_p, unsigned int _w_i_d_t_h, unsigned int _h_e_i_g_h_t, int _x___h_o_t, int _y___h_o_t); Pixmap XCreatePixmapFromBitmapData(Display *_d_i_s_p_l_a_y, Drawable _d, char *_d_a_t_a, unsigned int _w_i_d_t_h, unsigned int _h_e_i_g_h_t, unsigned long _f_g, unsigned int _b_g, unsigned int _d_e_p_t_h); Pixmap XCreateBitmapFromData(Display *_d_i_s_p_l_a_y, Drawable _d, char *_d_a_t_a, unsigned int _w_i_d_t_h, unsigned int _h_e_i_g_h_t);

ARGUMENTS

_b_i_t_m_a_p Specifies the bitmap.
_b_i_t_m_a_p___r_e_t_u_r_n Returns the bitmap that is created.
_d Specifies the drawable that indicates the screen.
_d_a_t_a Specifies the data in bitmap format.
_d_a_t_a Specifies the location of the bitmap data.
_d_a_t_a___r_e_t_u_r_n Returns the bitmap data.
_d_e_p_t_h Specifies the depth of the pixmap.
_d_i_s_p_l_a_y Specifies the connection to the X server.
_f_g
_b_g Specify the foreground and background pixel values to use.
_f_i_l_e_n_a_m_e Specifies the file name to use.
The format of the file name is operating-system dependent.
_w_i_d_t_h
_h_e_i_g_h_t Specify the width and height.
_w_i_d_t_h___r_e_t_u_r_n
_h_e_i_g_h_t___r_e_t_u_r_n Return the width and height values of the read in bitmap file.
_x___h_o_t
_y___h_o_t Specify where to place the hotspot coordinates (or -1,-1 if none are present)
in the file.
_x___h_o_t___r_e_t_u_r_n
_y___h_o_t___r_e_t_u_r_n Return the hotspot coordinates.

DESCRIPTION

The _X_R_e_a_d_B_i_t_m_a_p_F_i_l_e 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, _X_R_e_a_d_B_i_t_m_a_p_F_i_l_e returns _B_i_t_m_a_p_O_p_e_n_F_a_i_l_e_d. If the file can be opened but does not contain valid bitmap data, it returns _B_i_t_m_a_p_F_i_l_e_I_n_v_a_l_i_d. If insufficient working storage is allocated, it returns _B_i_t_m_a_p_N_o_M_e_m_o_r_y. If the file is readable and valid, it returns _B_i_t_m_a_p_S_u_c_c_e_s_s.

_X_R_e_a_d_B_i_t_m_a_p_F_i_l_e 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 _X_F_r_e_e_P_i_x_m_a_p when finished. If _n_a_m_e_x_hot and _n_a_m_e_y_hot exist, _X_R_e_a_d_B_i_t_m_a_p_F_i_l_e returns them to x_hot_return and y_hot_return; otherwise, it returns -1,-1.

_X_R_e_a_d_B_i_t_m_a_p_F_i_l_e can generate _B_a_d_A_l_l_o_c and _B_a_d_D_r_a_w_a_b_l_e errors.

The _X_R_e_a_d_B_i_t_m_a_p_F_i_l_e_D_a_t_a function reads in a file containing a bitmap, in the same manner as _X_R_e_a_d_B_i_t_m_a_p_F_i_l_e, 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 _X_F_r_e_e. The status and other return values are the same as for _X_R_e_a_d_B_i_t_m_a_p_F_i_l_e.

The _X_W_r_i_t_e_B_i_t_m_a_p_F_i_l_e 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 _B_i_t_m_a_p_O_p_e_n_F_a_i_l_e_d. If insufficient memory is allocated, _X_W_r_i_t_e_B_i_t_m_a_p_F_i_l_e returns _B_i_t_m_a_p_N_o_M_e_m_o_r_y; otherwise, on no error, it returns _B_i_t_m_a_p_S_u_c_c_e_s_s. If x_hot and y_hot are not -1, -1, _X_W_r_i_t_e_B_i_t_m_a_p_F_i_l_e writes them out as the hotspot coordinates for the bitmap.

_X_W_r_i_t_e_B_i_t_m_a_p_F_i_l_e can generate _B_a_d_D_r_a_w_a_b_l_e and _B_a_d_M_a_t_c_h errors.

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

_X_C_r_e_a_t_e_P_i_x_m_a_p_F_r_o_m_B_i_t_m_a_p_D_a_t_a can generate _B_a_d_A_l_l_o_c and _B_a_d_M_a_t_c_h errors.

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

_X_C_r_e_a_t_e_B_i_t_m_a_p_F_r_o_m_D_a_t_a can generate a _B_a_d_A_l_l_o_c error.

DIAGNOSTICS

_B_a_d_A_l_l_o_c
The server failed to allocate the requested resource or server memory.
_B_a_d_D_r_a_w_a_b_l_e
A value for a Drawable argument does not name a defined Window or Pixmap.
_B_a_d_M_a_t_c_h
An _I_n_p_u_t_O_n_l_y window is used as a Drawable.

SEE ALSO

XCreatePixmap(3X11), XPutImage(3X11)
_X_l_i_b _- _C _L_a_n_g_u_a_g_e _X _I_n_t_e_r_f_a_c_e