Re: pixmaps and xpm-transparency



Tobias Hintze wrote:
> i've some problems with transparency of XPMs using pixmaps.

Hi Tobias, you can do this with two pixmap widgets in gtk+-1.2.x (I
don't know if this is helpful):

-- 
static char *question_xpm [] = { 
"48 50 4 1 0 0",
/* colors */
"       s none  m none  c none",
".      s black    m black c black",
"X      s lightgoldenrod   m white c lightgoldenrod",
"o      s blue    m black c blue",
/* pixels */
"                                                ",
"                                                ",
"                                                ",
"                .........                       ",
"              ..XXXXXXXXX..                     ",
"             .XXXXXXXXXXXXX.                    ",
"           ..XXXXXXXXXXXXXXX.                   ",
"          .XXXXXXXXXXXXXXXXXX.                  ",
"          .XXXXXXXXXXXXXXXXXXX.                 ",
 ... etc.

                image = gdk_pixmap_create_from_xpm_d( main_window_gdk,
                        &mask, NULL, question_xpm );

        fixed = gtk_fixed_new();
        gtk_box_pack_start( GTK_BOX( hb ), fixed, FALSE, FALSE, 2 );
        gtk_widget_show( fixed );

        px = gtk_pixmap_new( image, mask );
        gtk_fixed_put( GTK_FIXED( fixed ), px, 10, 10 );
        gtk_widget_show( px );

        px = gtk_pixmap_new( image, mask );
        gtk_fixed_put( GTK_FIXED( fixed ), px, 20, 20 );
        gtk_widget_show( px );
-- 

I get two xpms, one on top of the other, with transparent stuff
transparent.

If you want to do the drawing yourself, you need to mess about with clip
masks on the GC. The source for gtkpixmap has some stuff you can cut out
to do this sort of basic compositing.

John




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