home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / windows / x / 16085 < prev    next >
Encoding:
Text File  |  1992-09-03  |  2.3 KB  |  60 lines

  1. Newsgroups: comp.windows.x
  2. Path: sparky!uunet!das.wang.com!wang!news
  3. From: izeek@techunix.technion.ac.il (Ilan Aisic)
  4. Subject: Re: Getting color names(char*).
  5. Reply-To: izeek@techunix.technion.ac.il (Ilan Aisic)
  6. Organization: Technion, Israel Inst. of Technology
  7. Date: Thu, 3 Sep 1992 11:38:15 GMT
  8. Message-ID: <1992Sep3.113815.1092@discus.technion.ac.il>
  9. References: <3533@unisql.UUCP>
  10. Sender: news@wang.com
  11. Lines: 47
  12.  
  13. In article <3533@unisql.UUCP> nandraj@unisql.UUCP (Nandraj Arni) writes:
  14. > ...
  15. >   Say, if you make an application with motif GUI. You want to get
  16. >the name of colors of some resources programmitically. How would
  17. >you do that at any level, Xlib, Xt or Motif?
  18. > ...
  19.  
  20. Well, I'm not sure how you do it from Motif. I've done something similar
  21. in an Xlib program.
  22. In X, the color names and specifications are listed in the color database
  23. file.  A textual version of it may be usually found in
  24. /usr/lib/X11/rgb.txt or $OPENWINHOME/lib/rgb.txt.
  25.  
  26. Two things you have to bare in mind:
  27. 1. You can display many more colors which don't have names than colors with
  28.    names.
  29. 2. Often, more than one color name in the color database refer to the same
  30.    RGB (Red Green Blue) values.
  31.  
  32. As far as I can remember, Xlib doen't provide a way to query a color rgb 
  33. spec or a color cell and get back a "known" color name.  Maybe because
  34. of the clear ambiguity that comes from (1) and (2) above.
  35. Xlib does provide a way to get the RGB values for a given color name
  36. with the function "XLookupColor".
  37.  
  38. If you still want to get the colorname, I suggest you process the rgb.txt
  39. file yourself and keep it in some kind of a data structure in your 
  40. application.  Then, when you want to get the name of a given colorcell,
  41. you may search this table to find the best match (a topic in itself
  42. regarding colors). Maybe you'll get a "hit" but then again, 
  43. may get more than one hit and you'll have to decide which one to use.
  44.  
  45.     ____
  46.      /  /   __
  47.     /  /   /_/ /| /
  48.  __/_ /__ / / / |/   o o o
  49.  
  50.                            Ilan Aisic
  51.            Israel                                 USA
  52. Voice:   972-4-344474                         1-914-644-7710
  53. Fax:     972-4-342492                         1-914-644-7763
  54. E-mail:  izeek@techunix.technion.ac.il        ilan@allink.com
  55. -- 
  56.  
  57.     ____
  58.      /  /   __ 
  59.     /  /   /_/ /| /
  60.