[Xcb] [Semi-off-topic] Few questions regarding X programming

Maxim Levitsky maximlevitsky at gmail.com
Sun Jan 20 13:27:02 PST 2008

On Saturday, 19 January 2008 05:46:10 Barton C Massey wrote:
> In message <200801190304.32694.maximlevitsky at gmail.com> you wrote:
> > But then the obvious question arises, how the X pixmaps are defined:
> > 
> > I know that there are 3 formats: 
> > 
> > XYBitmap - mono 'bitmap'
> > XYPixmap - Internet sources suggest that it holds all red values of pixels  
> > first, then all green values, and then the blue values - I will be glad to 
> > hear more about it, I am just curios.
> > 
> > ZPixmap - normal image, each pixel holds color information, but my question 
> > is:
> > 
> > Does ZPixmap hold RGB colors, or colormap indexes.
> > 
> > 
> > If it holds RGB, then I probably will use the second method, I will 
> > preallocate few colors, and use them to fill backgrounds, draw rectangles, 
> > some decorations, and most drawing will be done using pixmaps.
> > (Using MIT-SHM if available).
> Pixmap formats don't really have anything to do with
> colormaps.  Both XYPixmap and ZPixmap are alternate ways of
> representing arrays of pixels, which may be indexes into a
> colormap or may be true color values.  Don't use
> XYPixmap---it's an anachronism and a mistake.
> > Besides, all info about the bitmap formats is welcome.
> > The X protocol spec seems to be sparse about it
> See our new util/image library for an implementation of all
> of it.
> > 2) Can I ask more questions If I have them? :-)
> You'll get better answers quicker on
> xorg at lists.freedesktop.org.
>     Bart

Sorry for a bit late answer, 

I understand the colormaps much better now.

Can you tell me if I got this right:

There are two methods to deal with colormaps:

1. The old fashion way:

Treat AllocColor like pixel=RGB(r,g,b).
All colors that are required for drawing are allocated this way, and are (possibly) cached.

The pixmaps are also 8-bit, and have a small colormap attached to them.
When using them, first add their colors to palette.

But if the pixmaps are 16bit or higher images, thus pixels contain RGB data instead, then ether the toolkit has to scan whole pixmap
to see what colors were actually used which is slow, or still have a colormap attached to it.
Since this is very obsolete I won't go this way.

2. The true color emulation:

Allocate all/most entries in colormap for equally spaced colors, save the resulting pixels in a array,
And then use this array for all drawing, convert all pixmaps to use those pixels on the fly.

I will eventually implement #2, but for now I will just use TrueColor visuals.
Btw my video card supports 8-bit TrueColor visuals when used in 256 color mode.

Strangely an old S3 ViRGE also supports TrueColor visuals in 8-bit mode.

Best regards,
	Maxim Levitsky

More information about the Xcb mailing list