Converting old 8 Bit Colormap to 32 bit Colormap

Peter Harris peter.harris at hummingbird.com
Fri Nov 2 10:33:48 PDT 2007


Edward Slezak wrote:
> Thanks for the help. What I am really trying to do is
> create a rainbow color bar that starts with black on
> the left goes thru blues,greens,yellows,oranges, and
> finally red. The one that used to work is had 100
> colors in it. The code I posted was just a snippet. As
> you can see in the snippet I was slowly increasing the
> blue value without changing the Red or Green. Once
> blue hit 255 I started increasing green while reducing
> blue. I repeated this process to get my rainbow color
> bar. The rainbow colors were used to display data on a
> falling raster display. I have my falling raster code
> working but can not figure out how to create a color
> bar that looks like a rainbow consisting of 100
> colors. I had hoped I could still do this in a similar
> manner.

I assume you're drawing the bar with pairs of XSetForeground() and
XFillRectangle() or similar?

First you need to re-read my message, and change from StoreColor to
AllocColor. Then, instead of XSetForeground(icounter), you would use
XSetForeground(xcolors[icounter].pixel).

> Am I off my rocker????? I might just not
> understand the 32 bit colors. I always thought the
> standard RGB values was easy to understand.

That's exactly what TrueColor is: Don't think of it as having a color
"map". There is no mapping. The pixel value is composed of the RGB values.

> Any new manuals you could point me to would also be of
> help.

New manuals? I'm afraid not. But all this is described in the old
manuals. My 1990 edition of "X Window System Volume 2: Xlib Reference
Manual" describes things reasonably well in the XAllocColor entry.

Maybe start from http://tronche.com/gui/x/xlib/color/cell.html and
consider that TrueColor only ever has read-only color cells.

Peter Harris



More information about the xorg mailing list