home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / windows / x / 14402 < prev    next >
Encoding:
Internet Message Format  |  1992-07-26  |  2.4 KB

  1. Path: sparky!uunet!lccinc!sram
  2. From: sram@lccinc.UUCP (Siddharth Ram)
  3. Newsgroups: comp.windows.x
  4. Subject: Re: Changing Colormap RGB values...
  5. Summary: code for changing colorcell values
  6.      (useful for transparency)
  7. Keywords: colormap RGB XView
  8. Message-ID: <82@hallofjustice.UUCP>
  9. Date: 26 Jul 92 19:22:35 GMT
  10. References: <549@usafa.af.mil>
  11. Distribution: comp.windows.x
  12. Organization: LCC Inc., Arlington VA
  13. Lines: 59
  14.  
  15.  
  16. In article <549@usafa.af.mil>, hewitt@usafa.af.mil (Joe Hewitt) writes:
  17. > Problem:    How to dynamically change the RGB values in a colormap entry
  18. >             so that all objects using that colormap index automatically
  19. >             change to the new color (in XView or Xlib).
  20. > Request:    I would like to see sample code that changes the RGB
  21. >             values on the fly.  Can someone help?
  22.  
  23.  
  24. for implementing transparency, i used the piece of code below.
  25. trans is the transparecy index (specified thru a motif slider by the user)
  26. in the range of 0.0 - 1.0. rtrans = 1.0 - trans. app1_color is 
  27. the original color of one graphics layer and app2_color that of
  28. the other graphics image overlaid on top. the newly computer colors
  29. are stored in private colorcells, (I am using GXor (oring, not xoring)
  30. as the gc function to copy the two images on top of each other.
  31. Hence i use specific colorcells as decided by the oring of the
  32. original colorcell indices. this scheme is called interpolated
  33. transparency
  34.  
  35.  for (i = 16; i <= 128; i+=16)
  36.  {
  37.  for (j = 2; j <=8; j++)
  38.   {
  39.   clr.pixel = i|j;
  40.   clr.red = (unsigned short)((float)app1_color[j].red*trans)
  41.         + (unsigned short )anint((float)app2_color[k].red*rtrans);
  42.   clr.green = (unsigned short )((float)app1_color[j].green*trans)
  43.         + (unsigned short )((float)app2_color[k].green*rtrans);
  44.   clr.blue = (unsigned short)((float)app1_color[j].blue*trans)
  45.         + (unsigned short)((float)app2_color[k].blue*rtrans);
  46.  XStoreColor(disp,new_cmap,&clr);
  47.   }
  48.   k++;
  49.   }
  50.  XInstallColormap (disp,new_cmap);
  51.  XSetWindowColormap(disp,XtWindow(W),new_cmap);
  52.  XSync(disp,False);
  53.  return;
  54.  }
  55.  
  56. there are problems with this scheme. It uses a private colormap and 
  57. screen flashing is a nuisance.
  58.  
  59. could someone suggest ways of minimizing or getting rid of it ?
  60. has anyone experimented with other ways of implementing transparency ?
  61.  
  62.  
  63. siddharth Ram
  64. uunet!hallofjustice!sram
  65. LCC Inc. Arlington VA 22042.
  66. (703)516-7545
  67.  
  68. -- 
  69. .signature not included (empty)
  70.