[Glade-users] transparent pixmap

Tristan Van Berkom tristan.van.berkom at gmail.com
Tue Jun 6 22:12:35 EDT 2006


Jachym Cepicky wrote:

>Hallo,
>
>maybe a bit offtopic, but I'll try: How to make transparent pixmaps?
>
>Task: I need to display 2 layers in gtk.DrawingArea:
>
>    1 - background PNG file
>    2 - drawings over this file
>
>for 1, I use 
>    pixbuf =  gtk.gdk.pixbuf_new_from_file(tmpPpmFile)
>
>for 2, I use
>
>    pixmap.draw_line(...)
>
>When I call 
>
>    drawingarea.window.draw_pixbuf(...,pixbuf,0,0,0,0,.....)
>    drawingarea.window.draw_drawable(..., pixmap, ....)
>
>The area appears black. Places, which should be transparent, are just
>black :-(
>
>How would you perform this task?
>
>  
>
There are a few ways to do this:
    o With alpha channel:
       compositing is only available client side in GTK+ atm... that 
means that every time
       you composite the results must be sent to the X server. To 
accomplish this you must
       simply reverse your method: you must draw the pixbuf *on top* of 
the pixmap after
       drawing the pixmap, pixmaps have no transperency.
    o Without alpha channel:
       use gdk_pixbuf_render_pixmap_and_mask() to get a GdkPixmap and a 
GdkBitmap,
       you must then set the mask in the GdkGC that you plan to use with 
gdk_draw_drawable(),
       this will give you higher performance and no real transperency.

Cheers,
                              -Tristan

NOTE: this is infact off-topic... you'll get a wider audience for this 
type of question on
gtk-app-devel-list at gnome.org



More information about the Glade-users mailing list