[Xcb] BitBlt like method?

Peter Harris pharris at opentext.com
Mon Nov 23 12:52:13 PST 2009

Nadeem Syed wrote:
>  /" Summary: don't. There's probably a better way to do what you're really
>   trying to do. Why are you trying to scan a pixmap for a specific
>   color? "/
> // 
> Is there a better way to scan for a specific color? Please do tell :)

I still don't know what you're trying to do. Why are you trying to scan
for a specific color?

If you're doing image processing, odds are the image came from a
PutImage. Try to operate on the bits you already have, instead of asking
the server to send you another copy.

If you're trying to do interop between apps, try talking directly to the
app (via window properties, or SendClientMessage, or similar). Or even
reparent one window into the other.

If you're doing compositing: Look into the Render extension, if you can
rearrange your app to use the alpha channel instead of a particular color.

Without knowing *why* you're scanning for a particular color, I have a
hard time suggesting alternatives to GetImage.

> Or would it be better to go back to Xlib if there is no good solution
> for XCB yet?

Every bad thing I say about XCB's xcb_get_image goes double for Xlib's

XCB is just like Xlib, except with latency hiding (and less cruft). So
with XCB, you can kick off a GetImage early, do some other processing
(or even drawing), and then ask for the bits from the GetImage when
you're ready to actually use them.

Or if you're working with multiple images, with XCB you can kick off
multiple GetImage requests at once, avoiding a round-trip delay for each.

XCB is really great when you're dealing with lots of atoms, properties,
or other small data. It's just that GetImage is so horribly slow that
you might not notice as much advantage from using XCB. By the time you
sync the graphics pipe, then read the bits over the slow half of AGP,
even network latency might not be particularly noticeable. (I imagine
you already know that GetImage is a complete non-starter if the server
is on the other end of a DSL line).

XCB is not a new protocol. It is a new way of looking at the existing
X11 protocol.

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