[Xcb] Get RGBA image

Sam Varshavchik mrsam at courier-mta.com
Tue Aug 6 21:33:54 UTC 2019


Suhail Doshi writes:

> And how might you figure out what you have: 4 bits of RGBA or 5 bits with a  
> pad or something else? Docs feel a bit scant. 

This documentation would come from the base X protocol specification and the  
RENDER extension. xcb's documentation is strictly limited to the xcb library  
interface. And since the XCB library is, basically, just a thin wrapper  
layout on top of the underlying X protocol, there's very little to document.  
You are expected to already know and understand X and any relevant  
extensions.

Very generally, if you have an image it has to come from somewhere, so  
somewhere you must have a PICTURE, and a PICTFORMAT that goes with it.

The QueryPictFormats RENDER extension request returns the list of all  
pictformats that the X display server supports, so you search it for your  
pictformat, by its pictformat id, and that tells you how many bits are there  
in each color channel and where each color channel may be found in the  
pixel. Somewhere in the X protocol documentation there's a specification of  
how X images are padded. Putting two and two together lets you unravel the  
individual bits.

XCB uses a consistent naming convention, for naming each library function  
based on the extension and the request or reply it's for. For this one,  
xcb_render_query_pict_formats() sends the request,  
xcb_render_query_pict_formats_reply() parses the reply, and then the library  
gives you xcb_render_query_pict_formats_formats_iterator() to iterate over  
the returned list of pictformats. The library does not document what  
QueryPictFormats itself does, you're on your own for the specification of  
the base protocol and each extension that's supported by XCB.

When I originally started on my epic odyssey to build a widget toolkit, it  
took me a little bit of time to figure all of this out, but once I  
understood how XCB wraps the X protocol into the C interface, figuring out  
how to use each extension using XCB became easier, with each extension.

If you think that's hard, try to figure out how to use the X input method. I  
challenge anyone to find a complete explanation published anywhere in the  
intertubes.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://lists.freedesktop.org/archives/xcb/attachments/20190806/74f75189/attachment.sig>


More information about the Xcb mailing list