home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!lccinc!sram
- From: sram@lccinc.UUCP (Siddharth Ram)
- Newsgroups: comp.windows.x
- Subject: Re: Changing Colormap RGB values...
- Summary: code for changing colorcell values
- (useful for transparency)
- Keywords: colormap RGB XView
- Message-ID: <82@hallofjustice.UUCP>
- Date: 26 Jul 92 19:22:35 GMT
- References: <549@usafa.af.mil>
- Distribution: comp.windows.x
- Organization: LCC Inc., Arlington VA
- Lines: 59
-
-
- In article <549@usafa.af.mil>, hewitt@usafa.af.mil (Joe Hewitt) writes:
- >
- >
- > Problem: How to dynamically change the RGB values in a colormap entry
- > so that all objects using that colormap index automatically
- > change to the new color (in XView or Xlib).
- >
- > Request: I would like to see sample code that changes the RGB
- > values on the fly. Can someone help?
- >
-
-
- for implementing transparency, i used the piece of code below.
- trans is the transparecy index (specified thru a motif slider by the user)
- in the range of 0.0 - 1.0. rtrans = 1.0 - trans. app1_color is
- the original color of one graphics layer and app2_color that of
- the other graphics image overlaid on top. the newly computer colors
- are stored in private colorcells, (I am using GXor (oring, not xoring)
- as the gc function to copy the two images on top of each other.
- Hence i use specific colorcells as decided by the oring of the
- original colorcell indices. this scheme is called interpolated
- transparency
-
- for (i = 16; i <= 128; i+=16)
- {
- for (j = 2; j <=8; j++)
- {
- clr.pixel = i|j;
- clr.red = (unsigned short)((float)app1_color[j].red*trans)
- + (unsigned short )anint((float)app2_color[k].red*rtrans);
- clr.green = (unsigned short )((float)app1_color[j].green*trans)
- + (unsigned short )((float)app2_color[k].green*rtrans);
- clr.blue = (unsigned short)((float)app1_color[j].blue*trans)
- + (unsigned short)((float)app2_color[k].blue*rtrans);
- XStoreColor(disp,new_cmap,&clr);
- }
- k++;
- }
- XInstallColormap (disp,new_cmap);
- XSetWindowColormap(disp,XtWindow(W),new_cmap);
- XSync(disp,False);
- return;
- }
-
- there are problems with this scheme. It uses a private colormap and
- screen flashing is a nuisance.
-
- could someone suggest ways of minimizing or getting rid of it ?
- has anyone experimented with other ways of implementing transparency ?
-
-
- siddharth Ram
- uunet!hallofjustice!sram
- LCC Inc. Arlington VA 22042.
- (703)516-7545
-
- --
- .signature not included (empty)
-