[comp.windows.x] Is The Screen Color?

dbainbri@ics.uci.edu (David Bainbridge) (06/26/89)

  A while back someone asked about how to determine if the screen was
color or black and white.  I found this in a book I have by O'Reilly and
Associates. 

#include < "Standard X Includes" >

int		depth;

"Open Display, and get default screen"

depth = DisplayPlanes( display, screen );

if ( depth == 1 ) 
  "Screen is monochrome"
else
  "Screen is color"

I haven't tested this, but I hope it works, I plan to use it.

+---------------------------------------+-------------------------------------+
|					|				      |
| University of California, Irvine	|  dbainbri@ics.uci.edu		      |
|					|				      |
+---------------------------------------+-------------------------------------+

converse@EXPO.LCS.MIT.EDU (Donna Converse) (06/26/89)

> someone asked about how to determine if the screen was
> color or black and white.  I found this in a book I have by O'Reilly and
> Associates.

> depth = DisplayPlanes( display, screen );

Agh!  We just answered this a hundred questions ago! :-)

Would your application consider StaticGray and GrayScale visuals with
multiple shades of gray (more than 2 cells) to be color?  Is a GrayScale
visual just as suitable as a PseudoColor visual for your application?

If not, use XGetVisualInfo and walk down the list of visuals it returns
to find the best visual type for your application.  

Testing if the display has more than 1 plane only tells you if the 
hardware of the display is capable of displaying more than just black and
white.  It does not tell you anything about the characteristics of the
default visual of the display.  Don't assume that the default visual of 
an n-plane display is capable of displaying colors of the rainbow.


Donna Converse
converse@expo.lcs.mit.edu

kam@hpcvlx.HP.COM (Keith Marchington) (06/28/89)

/ hpcvlx:comp.windows.x / dbainbri@ics.uci.edu (David Bainbridge) /  1:52 pm  Jun 25, 1989 /

>   A while back someone asked about how to determine if the screen was
> color or black and white.  I found this in a book I have by O'Reilly and
> Associates. 
> 
> #include < "Standard X Includes" >
> 
> int		depth;
> 
> "Open Display, and get default screen"
> 
> depth = DisplayPlanes( display, screen );
> 
> if ( depth == 1 ) 
>   "Screen is monochrome"
> else
>   "Screen is color"
> 
> I haven't tested this, but I hope it works, I plan to use it.
> 
>+---------------------------------------+-------------------------------------+
>|					|				      |
>| University of California, Irvine	|  dbainbri@ics.uci.edu		      |
>|					|				      |
>+---------------------------------------+-------------------------------------+

No.  Definitely not.  On one of our tops, we implement a set of overlay
planes as a potential screen.  The overlays are two planes deep, but the 
visual is StaticGray, not color.  The only way to assure that you are using
a color visual is to check all of the available visuals of the screen 
(we also have another top that offers as many as three different visuals)
and select one from the set of color visuals: StaticColor, PseudoColor, 
DirectColor, and TrueColor.

Keith Marchington
Hewlett-Packard

dale@boing.UUCP (Dale Luck) (06/28/89)

In article converse@EXPO.LCS.MIT.EDU (Donna Converse) writes:
>
>> someone asked about how to determine if the screen was
>> color or black and white.  I found this in a book I have by O'Reilly and
>> Associates.
>
>> depth = DisplayPlanes( display, screen );
>
>Agh!  We just answered this a hundred questions ago! :-)
>
>
>Testing if the display has more than 1 plane only tells you if the 
>hardware of the display is capable of displaying more than just black and
>white.

Nor can you assume that black and white are displayed in a 1 bitplane
visual. It appears that the default servers preallocate or assign
black and white colors when it starts up. Since black and white seem
to have become synonomous with 0 and 1 (or 1 and 0) we have had to add
some command line arguments to redefine what white and black are,
faking the rest of the X server and clients out.

This could not be done in the rgb database either since some applications
seem to request colors via hardcoded numbers, even black and white
causing them to fail if I've told the system that black is really a
brown and white is a yellowish color.



-- 
Dale Luck     GfxBase/Boing, Inc.
{uunet!cbmvax|pyramid}!amiga!boing!dale

kennel@minnie.cognet.ucla.edu (Matthew Kennel) (06/30/89)

In article <18700@paris.ics.uci.edu> dbainbri@ics.uci.edu (David Bainbridge) writes:
>
>  A while back someone asked about how to determine if the screen was
>color or black and white.  I found this in a book I have by O'Reilly and
>Associates. 
>
>#include < "Standard X Includes" >
>int		depth;
>"Open Display, and get default screen"
>depth = DisplayPlanes( display, screen );
>if ( depth == 1 ) 
>  "Screen is monochrome"
>else
>  "Screen is color"
>
>I haven't tested this, but I hope it works, I plan to use it.
>

This seems wrong, at least to me, just on general principles.  The NeXT
machine is monochrome (well, really "di-chrome" if you count black & white) but
has more than one display plane.

Or by "color" do you include various shades of grey?  But I still think
there's a difference.

>| University of California, Irvine	|  dbainbri@ics.uci.edu		      |






Matt Kennel
kennel@cognet.ucla.edu

jim@EXPO.LCS.MIT.EDU (Jim Fulton) (06/30/89)

> Since black and white seem to have become synonomous with 0 and 1 
> (or 1 and 0)

Stomping this out was one of the differences between X10 and X11.  Poking
around on a few of the servers here I see (and I'm sure there are other
values used on different servers):

	BlackPixel:  0, 1, 253
	WhitePixel:  1, 0, 252

Applications that presume any particular values for BlackPixel() and
WhitePixel() are guaranteed to break.