1XReadBitmapFile(3) XLIB FUNCTIONS XReadBitmapFile(3)
2
3
4
6 XReadBitmapFile, XReadBitmapFileData, XWriteBitmapFile, XCre‐
7 atePixmapFromBitmapData, XCreateBitmapFromData - manipulate bitmaps
8
10 int XReadBitmapFile(Display *display, Drawable d, char *filename,
11 unsigned int *width_return, unsigned int *height_return, Pixmap
12 *bitmap_return, int *x_hot_return, int *y_hot_return);
13
14 int XReadBitmapFileData(char *filename, unsigned int *width_return,
15 unsigned int *height_return, unsigned char *data_return, int
16 *x_hot_return, int *y_hot_return);
17
18 int XWriteBitmapFile(Display *display, char *filename, Pixmap bitmap,
19 unsigned int width, unsigned int height, int x_hot, int y_hot);
20
21 Pixmap XCreatePixmapFromBitmapData(Display *display, Drawable d, char
22 *data, unsigned int width, unsigned int height, unsigned long
23 fg, unsigned long bg, unsigned int depth);
24
25 Pixmap XCreateBitmapFromData(Display *display, Drawable d, char *data,
26 unsigned int width, unsigned int height);
27
29 bitmap Specifies the bitmap.
30
31 bitmap_return
32 Returns the bitmap that is created.
33
34 d Specifies the drawable that indicates the screen.
35
36 data Specifies the data in bitmap format.
37
38 data Specifies the location of the bitmap data.
39
40 data_return
41 Returns the bitmap data.
42
43 depth Specifies the depth of the pixmap.
44
45 display Specifies the connection to the X server.
46
47 fg
48 bg Specify the foreground and background pixel values to use.
49
50 filename Specifies the file name to use. The format of the file name
51 is operating-system dependent.
52
53 width
54 height Specify the width and height.
55
56 width_return
57 height_return
58 Return the width and height values of the read in bitmap
59 file.
60
61 x_hot
62 y_hot Specify where to place the hotspot coordinates (or -1,-1 if
63 none are present) in the file.
64
65 x_hot_return
66 y_hot_return
67 Return the hotspot coordinates.
68
70 The XReadBitmapFile function reads in a file containing a bitmap. The
71 file is parsed in the encoding of the current locale. The ability to
72 read other than the standard format is implementation-dependent. If
73 the file cannot be opened, XReadBitmapFile returns BitmapOpenFailed.
74 If the file can be opened but does not contain valid bitmap data, it
75 returns BitmapFileInvalid. If insufficient working storage is allo‐
76 cated, it returns BitmapNoMemory. If the file is readable and valid,
77 it returns BitmapSuccess.
78
79 XReadBitmapFile returns the bitmap's height and width, as read from the
80 file, to width_return and height_return. It then creates a pixmap of
81 the appropriate size, reads the bitmap data from the file into the
82 pixmap, and assigns the pixmap to the caller's variable bitmap. The
83 caller must free the bitmap using XFreePixmap when finished. If
84 name_x_hot and name_y_hot exist, XReadBitmapFile returns them to
85 x_hot_return and y_hot_return; otherwise, it returns -1,-1.
86
87 XReadBitmapFile can generate BadAlloc and BadDrawable errors.
88
89 The XReadBitmapFileData function reads in a file containing a bitmap,
90 in the same manner as XReadBitmapFile, but returns the data directly
91 rather than creating a pixmap in the server. The bitmap data is
92 returned in data_return; the client must free this storage when fin‐
93 ished with it by calling XFree. The status and other return values are
94 the same as for XReadBitmapFile.
95
96 The XWriteBitmapFile function writes a bitmap out to a file in the X
97 Version 11 format. The name used in the output file is derived from
98 the file name by deleting the directory prefix. The file is written in
99 the encoding of the current locale. If the file cannot be opened for
100 writing, it returns BitmapOpenFailed. If insufficient memory is allo‐
101 cated, XWriteBitmapFile returns BitmapNoMemory; otherwise, on no error,
102 it returns BitmapSuccess. If x_hot and y_hot are not -1, -1,
103 XWriteBitmapFile writes them out as the hotspot coordinates for the
104 bitmap.
105
106 XWriteBitmapFile can generate BadDrawable and BadMatch errors.
107
108 The XCreatePixmapFromBitmapData function creates a pixmap of the given
109 depth and then does a bitmap-format XPutImage of the data into it. The
110 depth must be supported by the screen of the specified drawable, or a
111 BadMatch error results.
112
113 XCreatePixmapFromBitmapData can generate BadAlloc and BadMatch errors.
114
115 The XCreateBitmapFromData function allows you to include in your C pro‐
116 gram (using #include) a bitmap file that was written out by
117 XWriteBitmapFile (X version 11 format only) without reading in the bit‐
118 map file. The following example creates a gray bitmap:
119
120 #include "gray.bitmap"
121 Pixmap bitmap;
122 bitmap = XCreateBitmapFromData(display, window, gray_bits, gray_width, gray_height);
123
124 If insufficient working storage was allocated, XCreateBitmapFromData
125 returns None. It is your responsibility to free the bitmap using
126 XFreePixmap when finished.
127
128 XCreateBitmapFromData can generate a BadAlloc error.
129
131 BadAlloc The server failed to allocate the requested resource or
132 server memory.
133
134 BadDrawable
135 A value for a Drawable argument does not name a defined Win‐
136 dow or Pixmap.
137
138 BadMatch An InputOnly window is used as a Drawable.
139
141 XCreatePixmap(3), XPutImage(3)
142 Xlib - C Language X Interface
143
144
145
146X Version 11 libX11 1.6.9 XReadBitmapFile(3)