Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How do you tell whether display is mono or color?

0 views
Skip to first unread message

Liron Lightwood

unread,
Aug 5, 1992, 9:21:31 PM8/5/92
to
Date: Wed, 5 Aug 1992 00:23:30 GMT
Message-Id: <1992Aug5.0...@trl.oz.au>
Newsgroups: comp.windows.x
References: <1992Aug4.0...@trl.oz.au>
Sender: xpert-...@expo.lcs.mit.edu

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

Liron Lightwood

unread,
Aug 7, 1992, 9:56:21 PM8/7/92
to
0 new messages