Re: [gtk-list] How do I get r,g,b from gdk_gc_get_values?




I think I figured out the answer (at least it seems to work).  Please
let me know if this is wrong.  Also, do I need any other
"free/unref's" here?

  GdkGCValues gcv;
  GdkVisual *visual = gtk_widget_get_visual(GTK_WIDGET(w));
  GdkColormap *cmap = gtk_widget_get_colormap(GTK_WIDGET(w)); 
  GdkColorContext *cc = gdk_color_context_new(visual, cmap);
  GdkColor fg;

  gdk_gc_get_values(gc, &gcv);

  fg.pixel = gc.foreground.pixel;
  gdk_color_context_query_color(cc, &fg);

  gdk_color_context_free(cc);
  cc = NULL:

Thanks

-- 
Rob Browning <rlb@cs.utexas.edu>
PGP fingerprint = E8 0E 0D 04 F5 21 A0 94  53 2B 97 F5 D6 4E 39 30



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