luj@delta.ecn.purdue.edu (Jun Lu) (11/09/90)
I have a feeling that XAllocColor can never fail under normal conditions( valid cmap argument, normal operations of server, normal connections ) becasuse XAllocColor request finds the *closest* color entry in the color map if it is full. Am I right ? Thanks, -- -- Jun Lu Internet:luj@ecn.purdue.edu -- -- Aeronautics & Astronautics Bitnet: luj%ecn.purdue.edu@purccvm -- -- Purdue University UUCP: pur-ee!luj -- -- W. Lafayette, IN 47907 Phone:317-494-9410 Fax:317-494-0307 --
klee@wsl.dec.com (Ken Lee) (11/09/90)
In article <1990Nov8.174617.10793@ecn.purdue.edu>, luj@delta.ecn.purdue.edu (Jun Lu) writes: |> I have a feeling that XAllocColor can never fail under normal conditions( |> valid cmap argument, normal operations of server, normal connections ) |> becasuse XAllocColor request finds the *closest* color entry in the color |> map if it is full. XAllocColor finds the closest color supported by the visual, not the closest color in the colormap. It will fail if the requested color is not in the colormap and the colormap is full. XAllocNamedColor can also fail if the specified name is not in the color database. -- Ken Lee DEC Western Software Laboratory, Palo Alto, Calif. Internet: klee@wsl.dec.com uucp: uunet!decwrl!klee
baeder@cadence.com (D. Scott Baeder; x299) (11/09/90)
|> XAllocColor finds the closest color supported by the visual, not the |> closest color in the colormap. It will fail if the requested color is |> not in the colormap and the colormap is full. XAllocNamedColor can |> also fail if the specified name is not in the color database. |> This leads me to a problem Im having, in that what exactly is closest, and what is the best way to allocate colors so that you get approx. what your looking for, even if the color map is getting "full" any code frags appreciated... thanks...scott
etaylor@wilkins.iaims.bcm.tmc.edu (Eric Taylor) (11/10/90)
What we do here is the following: We allocate approximate 92 colors in the default colormap. We distribute the colors as uniformly as possible : num_red = num_green = num_blue = cube_root(256) Which essentially gives us a DEFAULT_RGB colormap in the default colormap. Image processing applications then reuse the exact same colors, doing color dithering (Floyd/Steinberg). This allows us to have many applications displaying colorful images at the same time using the default colormap. -- Eric Taylor Baylor College of Medicine etaylor@wilkins.bmc.tmc.edu (713) 798-3776
mouse@LARRY.MCRCIM.MCGILL.EDU (11/12/90)
>> XAllocColor finds the closest color supported by the visual, not the >> closest color in the colormap. It will fail if the requested color >> is not in the colormap and the colormap is full. (That's true for GrayScale, PseudoColor, and DirectColor. The first half of the first sentence is true for all six visuals; the second sentence is vacuously true for the three static visuals. (But see my note [$] below.)) > This leads me to a problem Im having, in that what exactly is > closest, and what is the best way to allocate colors so that you get > approx. what your looking for, even if the color map is getting > "full" It might not be possible. If someone has nearly filled up the colormap with a grayscale ramp, so there are only two cells left, and you want red, green, and blue, there really isn't much you can do: you simply can't get anything that is even approximately what you're looking for without creating your own colormap. Allocating a color on any visual will always, as a first step, approximate the requested color as closely as possible for that visual. Taking the resulting approximation as "the requested color", then - If the requested color is present in a read-only cell of the colormap, that cell is returned[#]; - Otherwise, if there is a cell free[%], it is filled in with the requested color and returned; - Otherwise, an error is generated. Note that the first step will always succeed for a static visual, because the colormap always contains all the colors the visual supports. [%] For DirectColor, this may be[$] more complicated than "if there is a cell free", because there are three distinct mapping tables involved, one for each primary. I haven't looked at it in detail. [$] I am not certain XAllocColor works for decomposed visuals (DirectColor and TrueColor); I haven't checked in detail. [#] What happens if more than one read-only cell contains the color is not quite as clear, though some one of them should be returned. Due to the semantics of allocating colors, this can happen only when a server implementor provides a static visual with redundant cells in the colormap. der Mouse old: mcgill-vision!mouse new: mouse@larry.mcrcim.mcgill.edu