jeff@osc.edu (Jeff Faust) (02/16/91)
I have a graphics application which needs to allocate many colors in the colormap in order to do quality shading. Specifically, 245 colors are used for a special dithering algoritithm, 8 colors are used for user interface colors, and the other 3 are leftover (assuming 256 colors). I use a pretty good scheme now, but users still complain about the colormap shifting when moving between applications. I could greatly reduce the colormap shifting if I could examine carefully the default colormap and try to match colors already allocated there to similiar colors in my dithering colormap. In otherwords if there is a red in the default colormap with a pixel value of 4, I would place a red in my colormap at the pixel value of 4 as well. Unfortunately, X11 seems to overlook this desire and it seems impossible (in a portable fashion) to determine which colors are already allocated in the default colormap. XAllocColor() and XAllocColors() come close but there is now way to detect unallocated colors from alloced colors. I don't want my code to bother to match what are garbage values in the colormap. Does anyone have any ideas about how to improve this situation? Thanks: Jeff Faust jeff@totem.osgp.osc.edu
ekberg@asl.dl.nec.COM (Tom Ekberg) (02/19/91)
From: jeff@osc.edu (Jeff Faust): > XAllocColor() and XAllocColors() come close but > there is now [sic] way to detect unallocated colors from alloced colors. I > don't want my code to bother to match what are garbage values in the > colormap. Does anyone have any ideas about how to improve this > situation? I have done a bit of work with allocating colors when only a small number (256) are available. Specifically, trying to display multiple GIF files at the same time when the total number of colors needed exceeds 256 and get a reasonable result. Anyway, the approach I used distinguished read-only pixels from read/write pixels. What you can do is to is to attempt an XStoreColor on a pixel. If the store succeeds then you know that you have a read/write pixel. If you get a BadAccess error then you have an unallocated or a read-only pixel. Of course, if you allocate all cells in the colormap first (assuming you are using a PseudoColor visual class) then if you get a BadAccess from a XStoreColor then you know you have a read-only pixel. -- tom, ekberg@aslss02.asl.dl.nec.com (x3503)