[cairo] 8 bit pseudo color missing.

Owen Taylor otaylor at redhat.com
Wed Mar 22 13:32:08 PST 2006


On Wed, 2006-03-22 at 13:12 -0800, Keith Packard wrote:
> On Wed, 2006-03-22 at 15:55 -0500, Owen Taylor wrote:
> 
> >    Floyd-Steinberg dithering, though it really doesn't work
> >    well for screen display due to discontinuities at the
> >    edges of dithered regions has the nice property that 
> >    it is easy to get going with an arbitrary color map
> >    rather than a color cube. As long as you have *some* way
> >    of finding an color in the color map that approximates
> >    the color of the pixel, then you'll get decent results.
> 
> I think an ordered dither makes a whole lot more sense here; it's both
> faster and generates stable results.

Certainly ordered dithers are in general better: especially if you
use large dither matrices. (A good large public domain table created
by Raph Levien can be found in gtk+/gdk/gdkrgb.c.) 

Stability is, however, somewhat compromised by the issue of a
"dither offset". If you don't handle that, then you frequently
get the problem that a small portion of the dither pattern is
repeated over and over again when scrolling or dragging a window
over to expose .. you get patterns like:

 *  *   *  *   *   *  *
 *  *   *  *   *   *  *
 *  *   *  *   *   *  *
 *  *   *  *   *   *  *
   *  *   *   *  *   *
 *   *   *  *   *  *  *
  *   *   *   *   *  *

The main reason I mentioned Floyd-Steinberg, however, here is that you
might be able to avoid writing the code to sniff out pre-allocated
color cubes that way. But you certainly will get better results
if you *do* sniff out existing color cubes and/or allocate your
own.

Regards,
					Owen

(One issue I didn't mention in my mail is that nothing in the Cairo
API really gives Cairo license to allocate colors from the system
colormap. 

One really cheap way of handling the color cube problem is just to
extend the API to let the user of Cairo *pass in* a color cube for
the display; after all GTK+ already has the code, and Eric apparently
was most worried about GTK+, not arbitrary usage of Cairo.)




More information about the cairo mailing list