- xf = XListPixmapFormats(display, &nxf);
- for (a = 0; a < nxf; a++)
- {
- if (xf[a].depth == depth)
- {
- int bpp;
- bpp = xf[a].bits_per_pixel;
- XFree(xf);
- return (unsigned int) bpp;
- }
- }
- XFree(xf);
+ /* get Pixmap formats supported by the X server */
+ pixmap_format = XListPixmapFormats(display, &num_pixmap_formats);
+
+ /* find format that matches the given depth */
+ for (i=0; i<num_pixmap_formats; i++)
+ if (pixmap_format[i].depth == depth)
+ bits_per_pixel = pixmap_format[i].bits_per_pixel;
+
+ XFree(pixmap_format);
+
+ if (bits_per_pixel == -1)
+ Error(ERR_EXIT, "cannot find pixmap format for depth %d", depth);