[Xcb] Get image/color data

Peter Harris pharris at opentext.com
Mon Nov 23 08:46:43 PST 2009


Rémi Denis-Courmont wrote:
> On Sun, 22 Nov 2009 08:05:22 -0500, Peter Harris <git at peter.is-a-geek.org>
> wrote:
>> On Sun, Nov 22, 2009 at 12:45 AM, Nadeem Syed wrote:
>>> How would I get the image of the provided handle device context
>> (window)?
>>
>> Please don't. GetImage is a very slow operation
> 
> But is there really any alternative for screenshot purposes?

Sorry, I answered that bit before I saw you say screenshot below.

ScreenShots are a special case. There are any number of screenshot
applications already. If you really want to re-invent the screenshot
wheel, GetImage is your only choice if you're limited to the core protocol.

The spec has this to say about GetImage: "This request is not
general-purpose in the same sense as other graphics-related requests. It
is intended specifically for rudimentary hardcopy support." (Where you
can read "screenshot" in the place of "hardcopy").

> I don't
> suppose Composite + GetImage is any better?

Yes, Composite + GetImage is better (if it is available). It lets you
operate on pixmaps instead of windows (operating on windows has a
propensity for throwing BadMatch errors, to pick one example).

>>> I
>>> need to get the image (screen shot basically) and then save it to as an
>>> image to the hard disk.
>> Are you sure? What are you really trying to do?
>>
>>> How would I got about doing this?
>> You don't. It's a bad idea. See above. But if you really, really need
>> to (and you probably don't), you can use:
>>
>> xwd -id <window id>
>>
>> http://cgit.freedesktop.org/xorg/app/xwd/
> 
> AFAICT, xwd does use GetImage internally. Why is that better?

It's not better. It's just sample code "if you really, really need to
(and you probably don't)".

If it sounds like I'm unreasonably biased against GetImage, I am. I've
just seen it used in too many places where it's inappropriate.

> Is there anything hybrid of Xephyr and Xvfb that would both display and use
> a shared memory frame buffer?

I'm afraid I don't know.

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


More information about the Xcb mailing list