reading a window's content with Xlib's XGetImage reveals portions of overlapping windows even with the backing store attribute set to Always

Peter Harris pharris at opentext.com
Thu Aug 20 13:02:43 PDT 2009


Amos Tibaldi wrote:
>    I am trying to read the content of a portion of a window with the
> function XGetImage:

> but when I read the pixels in anImage->Data, if there is a window that
> overlaps the
> region that I read (0, 0, 200, 200), the content of that window is
> returned in
> "anImage" instead of the original content of the window.
> I have tried to set the backing store attribute of the window desktopWin
> to "Always"
> in order to see if that could help, in fact:

>   3.2.4 Backing Store Attribute
> 
> Some implementations of the X server may choose to maintain the contents
> of InputOutput windows.

Key words "Some", "may", "choose". The BackingStore flag is just a hint.
The server is not required to honour it.

> Unfortunately it has not helped, since overlapping portions of
> other windows are still returned in anImage instead of the original
> content of the window that I want to grab. What could I do to solve
> this matter?

When drawing, draw to a pixmap then CopyArea the pixmap to your window.
Do the GetImage on the pixmap instead of the window. Some toolkits do
this automatically. All you'd have to do in that case is ask your
toolkit for its backing pixmap instead of its window.

Better yet, rework your code so you don't need to call GetImage.
GetImage is very slow.

Peter Harris
-- 
               Open Text Connectivity Solutions Group
Peter Harris                    http://www.opentext.com/connectivity
Research and Development        Phone: +1 905 762 6001
pharris at opentext.com            Toll Free: 1 877 359 4866



More information about the xorg mailing list