Converting old 8 Bit Colormap to 32 bit Colormap
Peter Harris
peter.harris at hummingbird.com
Fri Nov 2 09:55:53 PDT 2007
Edward Slezak wrote:
> I have not programmed X-Windows in some time. I have
> some old code that uses an 8 bit RGB colortable. My
> books do not show how to create a 32 bit colortable.
It generally isn't necessary, since TrueColor colours are not mutable,
nor are they a scarce resource.
> Any help would be appreciated. I just need a snippet
> of code that shows what to do. My code snippet is
> listed below.
Translated into pseudocode, you are doing roughly this:
XCreateColormap(alloc all)
loop
XStoreColor
end loop
The first step is to translate that into:
XCreateColormap(alloc none)
loop
XAllocColor
end loop
Note that you don't get to pick the pixel values, you have to use the
pixel values that the X server returns to you. The resulting code should
work with any kind of visual.
Then, if you detect you are on a TrueColor visual, you can skip the
XCreateColormap step, and just use the default colormap.
Peter Harris
More information about the xorg
mailing list