Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!rutgers!apple!ames!pasteur!ucbvax!hoptoad!gnu From: gnu@hoptoad.uucp (John Gilmore) Newsgroups: comp.windows.news Subject: Re: Playing with the colormaps Message-ID: <7358@hoptoad.uucp> Date: 19 May 89 00:53:45 GMT References: <406@crdgw1.crd.ge.com> <1501@murtoa.cs.mu.oz.au> Organization: Grasshopper Group in San Francisco Lines: 70 Since people seem to be interested in improving the color support in NeWS, here is a reposting and amplification of my ideas on the subject. The idea is to get exactly the colors you ask for, unless you ask for too many. Most "8 bit color" framebuffers can specify up to 256 24-bit colors. If you ask for 100 24-bit colors (by rendering something after calling setcolor with 100 different arguments) then you should see exactly those 100 colors on the screen. It's only if you ask for 300 24-bit colors that strange effects should occur; more below on that. This is one area where X/NeWS moves backwards instead of forwards, due to unimaginatively adopting the X color map model for NeWS. John Date: Thu Nov 3 23:37:00 1988 Subject: Re: Dithering and color maps Newsgroups: comp.windows.news I have some ideas on better ways to handle color maps in NeWS. Since the color model is already 24 bit, there should be no change to applications. What I'd like to do is have NeWS start off with an empty color map, and add colors to it as they are imaged. This means that unless you use more colors than your color map holds, you would always get exactly the colors you ask for. I find it very frustrating that with the color tools, I can slide the sliders all around and the same damn wrong color stares out at me; or that when sliding the 'saturation' or 'brightness' slider, the hue constantly changes. The hard part is of course what to do if more colors are requested than you can hold. The first is to garbage-collect; scan the screen and throw away any colors that are no longer in use. If you have garbage collected recently and you still have too many colors, it's time to fall back on the old method (pick a close color to what was requested / dither for 24-bit images) though we can probably do better by picking a color map that concentrates on the colors the user is actually using at the moment. For example, if there are no greens but seventy shades of yellow, maybe give them 40 shades of yellow and no greens. If you have to 'reclaim' colors that were in use, canvases which were using those color values become damaged and must repaint. This may cause applications a little trouble if they don't expect damage (e.g. if retained), though all applications 'should' always be willing to repair damage. Judicious choice of which colors to replace with which others should minimize the amount of wierd colors shown on the screen before the damage is repaired. The decision about when to use each algorithm above has a great bearing on performance and on how pretty the screen looks (how faithfully the colors are rendered). If you rebuild the map and damage many canvases each time a new color is used, performance will be poor; better to free up maybe 1/3 of the color map each time you rebuild it, and have 'image' operators look ahead to find the total set of colors used if they end up having to rebuild the color map, rather than do it several times in a single imaging (or end up with inferior color choices). Currently, all canvases of the same depth (8 bits only, in the current NeWS implementation) seem to use the same color map. This probably needs to be extended so that each unmapped canvas had its own color map (requiring color maps to be merged when the canvas is mapped to a screen, or in 'imagecanvas'). You can't assume a single frame buffer (at least in the Mac market, we can't), though currently NeWS won't run on multiple frame buffers; that will change sometime soon. Comments? -- John Gilmore {sun,pacbell,uunet,pyramid,amdahl}!hoptoad!gnu gnu@toad.com A well-regulated militia, being necessary to the security of a free State, the right of the people to keep and bear arms, shall not be infringed.