[pygtk] Xcomposite pixmap, convert to pixbuf with alpha channel

Stefan Stuhr gnomelists at sstuhr.dk
Mon Feb 16 00:55:56 WST 2009


Hello list,

I am making some code to take screenshots on X11. It works very well,
and now I want to take advantage of the Xcomposite extension, get the
offscreen pixmap of a window and convert it to a pixbuf, alpha channel
and all.

The example attached to this mail works, but I am using
pixbuf.get_from_drawable to convert the pixmap, and it doesn't include
the alpha channel in the pixbuf.

I am using the ctypes module to access the Xcomposite library.

This is the function I am using (from the Xcomposite man page):
        Pixmap XCompositeNameWindowPixmap(Display *dpy, Window window);

        [...]

        XCompositeNameWindowPixmap creates and returns a pixmap id that
        serves as a reference to the off-screen storage for window. This
        pixmap will remain allocated until freed, even if the window is
        unmapped, reconfigured or destroyed. However, the window will get
        a new pixmap allocated each time it is mapped or resized, so this
        function will need to be reinvoked for the client to continue to
        refer to the storage holding the current window contents.
        Generates a BadMatch error if window is not redirected or is not
        visible.
        
        The X server must support at least version 0.2 of the Composite
        Extension for XCompositeNameWindowPixmap.

How do I get the contents of the pixmap into a pixbuf, preserving the alpha channel? Any ideas?

Thanks,
Stefan
-------------- next part --------------
A non-text attachment was scrubbed...
Name: xcomposite-screenshot-test.py
Type: text/x-python
Size: 2510 bytes
Desc: 
Url : http://www.daa.com.au/pipermail/pygtk/attachments/20090215/5edea4ac/attachment.py 


More information about the pygtk mailing list