How to change color in a pixmap?



Hi,

My question is:
If I have a one-color pixmap (the other color is transparent) in a XPM
file
and I want to get a GtkPixmap widget with the same pixmap with the only
difference
that the only non-transparent color of the initial pixmap changed to
some other color determined in the runtime (say, the foreground color of
the main widget), what is
The Right Way to do it?

Let me explain the situation:
I want buttons in my application to have graphical rather than text
labels.
The easiest way is to follow the GTK+ Tutorial, Section 9.6:

        #include "pixmap.xpm"
        pixmap = gdk_pixmap_create_from_xpm_d( window->window,  &mask,
                                              
&style->bg[GTK_STATE_NORMAL],
                                               (gchar **)pixmap_xpm );
        pixmapwid = gtk_pixmap_new( pixmap, mask );
        gtk_container_add( GTK_CONTAINER(button), pixmapwid );

(unimportant comands are omitted)
My pixmaps are very simple: just some black symbols on transparent
background.
In the default GTK+ color scheme, it is fine: I have black pixmap labels
on
the gray background. However, if the default window background is dark,
the black
pixmaps will be unintelligible on it. So I want to change the color that
is black
in the files to the current foreground color. 

Browsing the documentation, I was able to figure out a couple of awkward
ways,
but is there an elegant way? I would like to avoid using the actual size
of the
pixmap in this procedure, since I have buttons (and pixmaps) of
different
sizes.

Thank you very much in advance.

Alexei.




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