This is GdkRgb.

Brief notes on using GdkRgb:

1. You must call gdk_rgb_init before using any GdkRgb functionality.
Inside widgets, it's entirely reasonable to place the call in the
class_init method.

2. GdkRgb tries to use the system default visual and colormap, but
doesn't always succeed. Thus, you have to be prepared to install the
visual and colormap generated by GdkRgb. The following code sequence
(before any widgets are created) should work in most applications:

  gdk_rgb_init ();

  gtk_widget_set_default_colormap (gdk_rgb_get_cmap ());
  gtk_widget_set_default_visual (gdk_rgb_get_visual ());

You can also push the colormap and visual, but that requires extra
care.

3. You can set the threshold for installing colormaps with
gdk_rgb_set_min_colors (). The default is 5x5x5 (125). If a colorcube
of this size or larger can be allocated in the default colormap, then
that's done. Otherwise, GdkRgb creates its own private colormap.
Setting it to 0 means that it always tries to use the default
colormap, and setting it to 256 means that it always creates a private
one. Note, however, that setting it to 0 doesn't let you get away with
ignoring the colormap and visual - a colormap is always created in
grayscale and direct color modes, and the visual is changed in cases
where a "better" visual than the default is available.

4. That done, the API is extremely simple. gdk_rgb_gc_set_foreground
sets the foreground color based on a simple 24-bit RGB color code.
gdk_draw_rgb_image draws a 24 bit RGB image into the drawable. The
arguments should be straightforward except for dither -
GDK_RGB_DITHER_NONE disables dithering, _MAX enables dithering if
supports (i.e. in most modes other than 24bpp ones), and _NORMAL
selects a default (usually on at 8bpp and off at 16bpp).

5. I've provided a few other functions that may improve performance
for image types other than 24bpp packed rgb. Of these, the gray one on
static gray visuals is the only one that gives a really large
performance jump.

6. Take a look at testrgb for notes on how to configure. Briefly:

+ include gdkrgb.c, gdkrgb.h, and gdkrgbstub.c in your source tree.

+ include gdkrgb.c and gdkrgb.h as EXTRA_DIST in the Makefile.am.

+ include gdkrgbstub.c in the program_SOURCES in the Makefile.am.

+ do an AC_C_BIGENDIAN test in configure.in.

+ include this code in all files that use gdk_rgb functions:

#ifndef GTK_HAVE_FEATURES_1_1_0
#include "gdkrgb.h"
#endif


Raph Levien

