doyle@b11.ingr.com (Doyle Davidson) (08/05/89)
I have a question about how color allocation is done on a StaticGray color display. I have a client (twm for example) that has its color parameters specified by names like "red", "blue", "thistle" etc... Upon running this on a StaticGray display, I discovered that the following occurs: Color R G B Gray level -------- --- --- --- ------------- "red" 255 0 0 33% "blue" 0 0 255 33% "green" 0 255 0 33% "black" 0 0 0 0% "white" 255 255 255 100% Now, I have read several interpretations and none really match this except for the code itself! 1) O'Reilly & Assoc: p.207 intensity = (0.30 * red) + (0.59 * green) + (0.11 * blue) really happens? WRONG! (no flame intended at O'Reilly & Assoc) 2) O'Reilly & Assoc: p.207 next sentence: "If only a GrayScale visual is available, the red value ONLY will be used for gray scale intensity" really happens? WRONG! I thought that #1 just said... owell. If #2 is right then "green" and "blue" should map to black. 3) I read the protocal on the distribution tape: nothing that I found said anything specific and is not part of the DDX layer :-( I remember reading in something that R G and B should all be set to the same value by the client because it cannot be sure which one of these three that the server will use as an intensity. I cannot find it now to quote from it unfortunately. 4) I looked at the code: it searches through the RGB values for the Grayscale color table (which are all the same) and finds the color that minimizes the following (in pseudocode): in dix/colormap.c: FindBestPixel() for (all RGB pixel values in table) value = (red_asked - red_table)^2 + (greed_asked - green_table)^2 + (blue_asked - blue_table)^2 /* like a 3D distance formula but no square root */ if (value < best_so_far) { pixel = current_pixel_being_testing_from_table; best_so_far = value; } really happens? Yes!! Hey this is it but not documented ANYWHERE Hey you guys at MIT, got the answer? Thanks in advance, Doyle (I RTFMs and am still confused :-O ) Davidson ------------------------------------------------------------------ Doyle C. Davidson | Intergraph Corp. | These comments are... Workstation Graphics Standards | 1 Madison Industrial Park | Huntsville, AL 35806 | (205) 772-2000 | X-clusively my own. | ..!uunet!ingr!b11!doyled!doyle | ------------------------------------------------------------------
rws@EXPO.LCS.MIT.EDU (08/07/89)
I have a question about how color allocation is done on a StaticGray color display. You get the "closest RGB values provided by the hardware". That's all the protocol says, for better or for worse. I remember reading in something that R G and B should all be set to the same value by the client because it cannot be sure which one of these three that the server will use as an intensity. This is only when storing (StoreColors) into a GrayScale map. finds the color that minimizes the following ... really happens? Yes!! Hey this is it but not documented ANYWHERE Because it's not part of the protocol specification. (Also, you missed an important part of the implementation, which is that ResolveColor gets called, and it can transform the RGB values. For example, in the server I'm typing at, it transforms to a gray value according to the 30/59/11 percentages. Since the GrayScale map happens to have been initialized similarly, the FindBestPixel code pretty much ends up actually looking for equality. Since ResolveColor can vary with each ddx, it's kinda hard to provide a single description of what the sample server chooses to do for this implementation-dependent detail.)