Re: Get RGBA image

Sam Varshavchik <[email protected]> Tue, 06 Aug 2019 17:33:54 -0400
Newsgroups gmane.comp.freedesktop.xcb
Message-ID <[email protected]>
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.

_______________________________________________
Xcb mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/xcb
signature.asc (application/pgp-signature, 833 B)
-----BEGIN PGP SIGNATURE-----

iQIzBAABCAAdFiEEMWrVnbBKLOeG9ifkazpiviedvyUFAl1J8kIACgkQazpivied
vyX4qQ//YwhEuRiMcAP9+wzAJXMAKtJ9WqZUbWIa2lv8FrgoXwXzmUG1anrqKpX2
Zc/KvZ+SUcVL1bO2FWvbXyBeoaqWvlQQ/Qf5lmrpNQ0KJ/BcExxsNh0oSCgkQoEo
vvewX3AhYrCPJ/tyH8OAQYjREOtqdJTQxLwmQhisiWm/vF9E/6k4y+X4W7bL6RqC
Tl5dSg14Ut/i0P+SVpt7liVfxLKi8HadNsyTTo2Wlm3gEmVq79vbBxycF/Z6wsky
OKuPhVTmgN8Y0dusvh7x711J8NQoWDHoD1tqyMDPrW1QXVP9KL2y4vO+J6wfI47R
WfmAJo9EhvOW63Lcv+5LXYO5Y88z8H/DSjuRW53ySMW5GZStYxGwyPeNBa5+VKUx
RdgEq4t22Kfwgq3QN5pe+PXUoopBno2E12M1qiubqBJ5HPedjiAuwHDIcenoHhZ4
dP21fl52TJsPMJX4dxOqC7hffW5UWbDHcVg09bT81bjCdq9mo7nU2rsH0hGC6Z9b
rOyYoS7CMnm+AG1fSxM7SGx8CSU1i5SioiUGbB43vw+42AJ/0GXYy1cCQoe1EctT
Jm5I4J4+Ofsyy5+MxBsKnxfr10l1K84FdhrBgjbDC9JKnA/u9kRByVu5aAze+hV3
SxJ2s0Jp8w0xnqThV/rtC0PlSn6JgQHR6ylNY6X3n9+MkaPDmUc=
=z5qt
-----END PGP SIGNATURE-----