lig...@cetra.trl.OZ.AU (Liron Lightwood) writes:
>Is there a quick way for a program to know whether a particular display is
>monochrome or color?
>Please reply by email. I will post summaries later.
Thank you for all your replies. Here is the summary I promised.
From: whe...@vulcan1.hac.com (Bob Wheeler ird)
If the screen is binary, then the number of bits associated with it is 1.
From: ron...@cs.kun.nl (Ronald Pikkert)
The macro:
DisplayPlanes(display, screen)
will provide the depth of the display.
From: Basile STARYNKEVITCH <bas...@soleil.SERMA.cea.fr>
Look at the DefaultDepth and DisplayPlanes macros. Anyway the
information is in the Display structure - it is filled at connection
setup (by XOpenDisplay)
From: Brian Keck <b.keck>
Did you know about xdpyinfo?
Brian K
From: Tom Ivar Helbekkmo <t...@barsoom.nhh.no>
Yup. It's a macro in <X11/Xlib.h>. Having opened a display, and
decided on a screen to use within that display, the DisplayCells()
macro will tell you how many colorcells it has. Here's the relevant
bit of code lifted from tvtwm:
if (DisplayCells(dpy, scrnum) < 3)
Scr->Monochrome = MONOCHROME;
else
Scr->Monochrome = COLOR;
From: ph...@medici.trl.OZ.AU (Phil Nicholson)
Here's a code fragement that I use to do this:
vinfo_mask = VisualClassMask;
vinfo_template.class = PseudoColor;
visual = XGetVisualInfo(dpy, vinfo_mask, &vinfo_template, &dummy);
if (visual) {
colormap = XCreateColormap(dpy, RootWindow(dpy, screen),
visual->visual, AllocAll);
valuemask |= CWColormap;
attributes.colormap = colormap;
}
else {
vinfo_mask = VisualNoMask;
visual = XGetVisualInfo(dpy, vinfo_mask, &vinfo_template,
&dummy);
colormap = NULL;
}
win = XCreateWindow(dpy, RootWindow(dpy, screen),
sizehints.x, sizehints.y, (unsigned int)sizehints.width,
(unsigned int)sizehints.height, BORDER_WIDTH,
visual->depth, InputOutput, visual->visual,
valuemask, &attributes);
------
Thanks once again to those who replied.
Liron Lightwood Internet : r.lig...@trl.oz.au
Telecom Research Laboratories Phone : +61 3 253 6535
770 Blackburn Road Snail : P.O. Box 249 Clayton 3168 Australia
Clayton Vic. 3168 Australia Disclaimer : My views are not my company's