1XReadBitmapFile(3)              XLIB FUNCTIONS              XReadBitmapFile(3)
2
3
4

NAME

6       XReadBitmapFile,     XReadBitmapFileData,    XWriteBitmapFile,    XCre‐
7       atePixmapFromBitmapData, XCreateBitmapFromData - manipulate bitmaps
8

SYNTAX

10       int XReadBitmapFile(Display *display, Drawable d, _Xconst  char  *file‐
11              name,  unsigned  int *width_return, unsigned int *height_return,
12              Pixmap *bitmap_return, int *x_hot_return, int *y_hot_return);
13
14       int XReadBitmapFileData(_Xconst char *filename, unsigned int *width_re‐
15              turn,  unsigned int *height_return, unsigned char **data_return,
16              int *x_hot_return, int *y_hot_return);
17
18       int XWriteBitmapFile(Display *display, _Xconst char  *filename,  Pixmap
19              bitmap,  unsigned int width, unsigned int height, int x_hot, int
20              y_hot);
21
22       Pixmap XCreatePixmapFromBitmapData(Display *display, Drawable  d,  char
23              *data,  unsigned  int  width, unsigned int height, unsigned long
24              fg, unsigned long bg, unsigned int depth);
25
26       Pixmap XCreateBitmapFromData(Display *display, Drawable d, _Xconst char
27              *data, unsigned int width, unsigned int height);
28

ARGUMENTS

30       bitmap    Specifies the bitmap.
31
32       bitmap_return
33                 Returns the bitmap that is created.
34
35       d         Specifies the drawable that indicates the screen.
36
37       data      Specifies the data in bitmap format.
38
39       data      Specifies the location of the bitmap data.
40
41       data_return
42                 Returns the bitmap data.
43
44       depth     Specifies the depth of the pixmap.
45
46       display   Specifies the connection to the X server.
47
48       fg
49       bg        Specify the foreground and background pixel values to use.
50
51       filename  Specifies  the file name to use.  The format of the file name
52                 is operating-system dependent.
53
54       width
55       height    Specify the width and height.
56
57       width_return
58       height_return
59                 Return the width and height values  of  the  read  in  bitmap
60                 file.
61
62       x_hot
63       y_hot     Specify  where  to place the hotspot coordinates (or -1,-1 if
64                 none are present) in the file.
65
66       x_hot_return
67       y_hot_return
68                 Return the hotspot coordinates.
69

DESCRIPTION

71       The XReadBitmapFile function reads in a file containing a bitmap.   The
72       file  is  parsed in the encoding of the current locale.  The ability to
73       read other than the standard format  is  implementation-dependent.   If
74       the  file  cannot  be opened, XReadBitmapFile returns BitmapOpenFailed.
75       If the file can be opened but does not contain valid  bitmap  data,  it
76       returns  BitmapFileInvalid.   If  insufficient working storage is allo‐
77       cated, it returns BitmapNoMemory.  If the file is readable  and  valid,
78       it returns BitmapSuccess.
79
80       XReadBitmapFile returns the bitmap's height and width, as read from the
81       file, to width_return and height_return.  It then creates a  pixmap  of
82       the  appropriate  size,  reads  the  bitmap data from the file into the
83       pixmap, and assigns the pixmap to the caller's  variable  bitmap.   The
84       caller  must  free  the  bitmap  using  XFreePixmap  when finished.  If
85       name_x_hot  and  name_y_hot  exist,  XReadBitmapFile  returns  them  to
86       x_hot_return and y_hot_return; otherwise, it returns -1,-1.
87
88       XReadBitmapFile can generate BadAlloc and BadDrawable errors.
89
90       The  XReadBitmapFileData  function reads in a file containing a bitmap,
91       in the same manner as XReadBitmapFile, but returns  the  data  directly
92       rather  than  creating  a pixmap in the server.  The bitmap data is re‐
93       turned in data_return; the client must free this storage when  finished
94       with  it  by calling XFree.  The status and other return values are the
95       same as for XReadBitmapFile.
96
97       The XWriteBitmapFile function writes a bitmap out to a file  in  the  X
98       Version  11  format.   The name used in the output file is derived from
99       the file name by deleting the directory prefix.  The file is written in
100       the  encoding  of the current locale.  If the file cannot be opened for
101       writing, it returns BitmapOpenFailed.  If insufficient memory is  allo‐
102       cated, XWriteBitmapFile returns BitmapNoMemory; otherwise, on no error,
103       it  returns  BitmapSuccess.   If  x_hot  and  y_hot  are  not  -1,  -1,
104       XWriteBitmapFile  writes  them  out  as the hotspot coordinates for the
105       bitmap.
106
107       XWriteBitmapFile can generate BadDrawable and BadMatch errors.
108
109       The XCreatePixmapFromBitmapData function creates a pixmap of the  given
110       depth and then does a bitmap-format XPutImage of the data into it.  The
111       depth must be supported by the screen of the specified drawable,  or  a
112       BadMatch error results.
113
114       XCreatePixmapFromBitmapData can generate BadAlloc and BadMatch errors.
115
116       The XCreateBitmapFromData function allows you to include in your C pro‐
117       gram  (using  #include)  a  bitmap  file  that  was  written   out   by
118       XWriteBitmapFile (X version 11 format only) without reading in the bit‐
119       map file.  The following example creates a gray bitmap:
120
121       #include "gray.bitmap"
122       Pixmap bitmap;
123       bitmap = XCreateBitmapFromData(display, window, gray_bits, gray_width, gray_height);
124
125       If insufficient working storage  was  allocated,  XCreateBitmapFromData
126       returns  None.   It  is  your  responsibility  to free the bitmap using
127       XFreePixmap when finished.
128
129       XCreateBitmapFromData can generate a BadAlloc error.
130

DIAGNOSTICS

132       BadAlloc  The server failed  to  allocate  the  requested  resource  or
133                 server memory.
134
135       BadDrawable
136                 A  value for a Drawable argument does not name a defined Win‐
137                 dow or Pixmap.
138
139       BadMatch  An InputOnly window is used as a Drawable.
140

SEE ALSO

142       XCreatePixmap(3), XPutImage(3)
143       Xlib - C Language X Interface
144
145
146
147X Version 11                     libX11 1.8.1               XReadBitmapFile(3)
Impressum