[developer] gdk transparent xmp image



Hi,

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,
                                           color,
                                           (gchar **)xpm_data);
       
    gdk_gc_set_clip_mask (gc, mask);
    
    gdk_draw_drawable (pixmap_playground,
                       widget->style->fg_gc[GTK_STATE_NORMAL],
                       pixmap,
                       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
background.

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?

Thanks
Andreas


[1]
http://www.informit.com/isapi/product_id~%7BC172F74A-E1B2-48FA-81CA-F9C3C079322D%7D/element_id~%7BAFA21298-D093-44CB-9993-7E574420A176%7D/st~%7B8B377B75-8B63-4AEA-BEA1-4917BA2DDED0%7D/session_id~%7BE71BC8E9-DE54-4C9C-A667-72E666F1DC08%7D/content/articlex.asp

Ups, a little long ;-)



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