[comp.windows.x] Does anyone have any working XGetRGBColormap code?

aipdc@castle.ed.ac.uk (Paul Crowley) (03/14/91)

I have code that needs the colourmap set up such that different colours
are on different bitplanes, so when gc.function == GXor, and I plot
something red over something blue, the resulting pixel will be magenta.
I'm also trying to be sociable about it with regards to other programs.

First, on what window should I be calling XGetRGBColourmaps?  I'm using
the root and getting nada.

Secondly, what is it giving me back?  Is it placing a pointer to an
array of XStandardColormaps in whatever the third argument points to,
and mallocing the space for the array?  If so, do I need to free it?

Thirdly, if the property does not exist, how should I go about creating
it?  This seems to me the toughie.  It seems to me I have to search all
the visuals for a suitable one (ie one of PseudoColor or DirectColor)
set up a suitable colormap, and define the property.  This seems like
hassle, and if anyone has done it already, could they contact me?

Thanks,
                                         ____
\/ o\ Paul Crowley aipdc@uk.ac.ed.castle \  /
/\__/ Part straight. Part gay. All queer. \/

mouse@lightning.mcrcim.mcgill.EDU (der Mouse) (03/15/91)

> I have code that needs the colourmap set up such that different
> colours are on different bitplanes, so when gc.function == GXor, and
> I plot something red over something blue, the resulting pixel will be
> magenta.

This is not always possible as phrased; you would have to be running on
a server with colormap cell 0 either unallocated or containing black,
for starters.

However, if you use XAllocColorPlanes to ask for one pixel and three
planes, fill your drawable with the pixel, and then set the planemask
of the GC to the OR of the three planes, you will get much the same
effect.

> First, on what window should I be calling XGetRGBColourmaps?  I'm
> using the root and getting nada.

Perhaps nobody has yet created any standard colormaps on that screen
yet.  (I believe the root *is* the correct window.)

> Secondly, what is it giving me back?  Is it placing a pointer to an
> array of XStandardColormaps in whatever the third argument points to,
> and mallocing the space for the array?

That's how I'd interpret the description in the Xlib document.

> If so, do I need to free it?

I would guess so.  The description doesn't explicitly say, which seems
odd, but you should probably use XFree().

> Thirdly, if the property does not exist, how should I go about
> creating it?

Run xstdcmap :-)  If you want to do it from your program, steal code
from xstdcmap.

					der Mouse

			old: mcgill-vision!mouse
			new: mouse@larry.mcrcim.mcgill.edu