[developer] gdk transparent xmp image


Ihope someone could help me with my gdk problem. Since my last gdk
question I found some help here¹. Here is a piece of my code:

if (event->button == 1 && pixmap_playground != NULL)
    gc = gdk_gc_new (widget->window); /* 1a */
    //gc = widget->style->fg_gc[GTK_STATE_NORMAL]; /* 1b */
    color = (GdkColor *) g_malloc (sizeof (GdkColor));   
    /* 2a */
    red = 50;
    green = 155;
    blue = 50;
    /* * 2b *
    red = 0;
    green = 0;
    blue = 0;
    color->red = red * (65535/255);
    color->green = green * (65535/255);
    color->blue = blue * (65535/255);

    color->pixel = (gulong)(red*65536 + green*256 + blue);

    gdk_color_alloc(gtk_widget_get_colormap(widget), color);
    style = gtk_widget_get_style (widget);
    pixmap = gdk_pixmap_create_from_xpm_d (widget->window, &mask,
                                           (gchar **)xpm_data);
    gdk_gc_set_clip_mask (gc, mask);
    gdk_draw_drawable (pixmap_playground,
                       0, 0,
                       event->x, event->y,
                       16, 16);

I've drawn a background in a pixmap and copy it to an drawing_area like
in the scribbe-example. The code above is inside a button_press_callback
and should paint a xpm image with full translucence on the background.

I tired to get some ideas from ¹, but I didn't succed at all.

The xpm image in my code is a black and white only image with 16x16
pixels. If I execute the code avove it will clip the xpm image with the
color of the background image (here: green) and paint it on the

The only problem is, that if another object is yet under the new object
it should be clipped under the new object. But the new object is only
clipped with the background color an overwrites the old object instead
of clipping it.

Is this understandable? ;-)

Could someone point me to a solution for my problem?



Ups, a little long ;-)

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