Re: [gtk-list] Palette Management



	 My question is... How does Linux, or rather X Windows under 
   Linux, manage the system palette?  Is it a similar process where
   the system wants to have specific colors mapped into the palette
   at all times?  
	 The question stems from an observation that if I attempt to display
   a 256 color bitmap, I do not get all of the colors in the palette.  

There is no system palette.  If you install a custom colormap for your
application, you get all 256 (if you have eight bit pixels) entries;
if you use the default colormap, you get all that's left over after
everybody else has used the default colormap for whatever they want.
What's probably happened in the case you're describing is that the
application doesn't install its own colormap.

An application of mine starts by looking to see if there are enough
colors in the default colormap to use it; if there are, it does, if
there aren't it creates its own colormap.  There is a race condition
here (somebody else could grab up all the colors in between my
checking and allocating all the colors I need), but that hasn't been a
problem in practice.  When I create my own colormap, I copy the first
40 colors or so from the old map into the new one, so the background
image and the window decorations don't go nuts when I move the cursor
into my window.
-- 
Joseph J. Pfeiffer, Jr., Ph.D.       Phone -- (505) 646-1605
Department of Computer Science       FAX   -- (505) 646-1002
New Mexico State University          http://www.cs.nmsu.edu/~pfeiffer



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]