home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!olivea!hal.com!darkstar.UCSC.EDU!bering!craig
- From: craig@bering.ucsc.edu (Craig Schiavone)
- Newsgroups: comp.windows.x
- Subject: Re: 24 bit Colour in X.
- Message-ID: <1k1f1lINN8r7@darkstar.UCSC.EDU>
- Date: 25 Jan 93 19:28:52 GMT
- References: <1993Jan25.092842.16287@cs.nott.ac.uk>
- Reply-To: craig@ucsc
- Organization: Sun Microsystems, Inc.
- Lines: 56
- NNTP-Posting-Host: bering.ucsc.edu
-
- In article 16287@cs.nott.ac.uk, nlc@trellis.cs.nott.ac.uk (Neil L Cook) writes:
- >I am looking for advice and or examples of code in how to program
- >24-bit colour in Xlib. I have a GS card for the SPARC10 which is
- >capable of theoretically displaying all 16.7 million at once. I have
- >read the O'Reilly Xlib Programmers guide, but it is extremely sketchy
- >about using all the colours at once, going on about using a colourmap
- >for each primary. The Xlib manual talks about plane masks which u
- >apply to the index into the colourmap.
- >
- >Specifically, I am looking for the arguments to XAllocColourPlanes,
- >which seems to die if I give it 256 colours and 8 bit rgb planes.
- >(Only accepts 1 colour and 8 bit rgb).
- >
- >Also, once I have got XAllocColourPlanes to work, what do I do with
- >these plane masks I get back? An example using e.g XPutPixel would be
- >nice.
- >
- >Neil.
-
- To use the 24 bits of color, you need to use a specific Visual for
- the window that you will be using. O'Reilly explains these in chapter
- Seven. What you'll need to do is get a pointer to the correct 24-bit
- visual, get a colormap structure to match it, and then open up a window
- with that visual, colormap, and a depth of 24 (I'm assuming it will be
- 24. It might be different for your system). This is how I'm doing it
- with the Xlib and Xt calls:
-
- stat = XMatchVisualInfo(disp, DefaultScreen(disp), 24, TrueColor, &vInfo);
- *trueColor24 = vInfo.visual;
- trueColor_cmap = XCreateColormap(disp, xmRootWindow, trueColor24, AllocNone);
- .
- .
- .
- movieWindow.topWindow = XtVaAppCreateShell("moviewindow", "XMex",
- topLevelShellWidgetClass, disp, XtNtitle, "Movie Window",
- XtNvisual, trueColor24, XtNdepth, 24, XtNcolormap, trueColor_cmap,
- NULL);
-
- You don't need to use a colormap for each primary. That's what a DirectColor
- visual can do, but chances are you don't need it. For a 24-bit TrueColor visual,
- you will likely derive pixel values something like this:
-
- unsigned char blue, green, red;
- unsigned int pixel;
- .
- .
- pixel = (blue << 16) || (green << 8) || red;
-
- ...or in a similar way. Different servers work will have different ways
- of computing the pixel value. The O'Reilley manual is more specific on
- that point.
-
- Opening a window with a specific Visual is a problem I haven't worked
- out satisfactorily for pure Xlib stuff, though. Hope this helps,
-
- -Craig
-