- unsigned i = 0;
- int count, result;
- XPixmapFormatValues *formats = XListPixmapFormats(dpy, &count);
-
- /* XCreateImage calls _XGetBitsPerPixel to figure this out, but that function
- is private to Xlib.
-
- For some reason, _XGetBitsPerPixel tries a hard-coded list of depths if
- it doesn't find a matching pixmap format, but I (Dave Odell) couldn't
- find any justification for this in the X11 spec. And the XFree86 CVS
- repository doesn't quite go back far enough to shed any light on what
- the deal is with that.
- http://cvsweb.xfree86.org/cvsweb/xc/lib/X11/ImUtil.c
-
- The hard-coded list apparently was added between X11R5 and X11R6.
- See <ftp://ftp.x.org/pub/>.
- */
-
- if (!formats) return 0;
-
- for (;;)
- {
- if (i == (unsigned)count)
- {
- result = 0;
- break;
- }
-
- if (formats[i].depth == depth)
- {
- result = formats[i].bits_per_pixel;
- break;
- }
-
- ++i;
- }
-
- XFree (formats);
- return result;
+ XVisualInfo *vi_out = visual_info (screen, visual);
+ *red_mask = vi_out->red_mask;
+ *green_mask = vi_out->green_mask;
+ *blue_mask = vi_out->blue_mask;
+ XFree ((char *) vi_out);