home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / windows / x / 21543 < prev    next >
Encoding:
Internet Message Format  |  1993-01-25  |  2.7 KB

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