Re: More questions on Colormaps and crashes...



Hi,

This isn't really answering the question, but you would probably save
yourself a lot of headaches by doing the following:

 - create your widget to draw on with the GdkRGB visual and colormap:
    gtk_widget_push_visual (gdk_rgb_get_visual ());
    gtk_widget_push_colormap (gdk_rgb_get_cmap ());
    mywidget = my_widget_new ();
    gtk_widget_pop_visual ();
    gtk_widget_pop_colormap ();

 - Allocate colors as follows:
   /* 0xff442e means 0xff red, 0x44 green, 0x2e blue */
   color.pixel = gdk_rgb_xpixel_from_rgb (0xff442e);

 - be sure you create your GC using widget->window or otherwise 
   ensuring it's using the visual from gdk_rgb_get_visual()

 - Don't worry about freeing colors.

In GTK 1.3, this is a bit simpler:

 GdkColor color;
 color.red = 65535;
 color.green = 30000;
 color.blue = 20343;
 gdk_gc_set_rgb_fg_color (gc, &color);

In 1.3 there is no need to push a special visual on widget creation, 
GdkRGB will work with any visual.

Havoc





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]