[Xcb] Best way to load a png/jpeg file when using XCB?

Vincent Torri vtorri at univ-evry.fr
Sun Jul 4 09:40:04 PDT 2010

On Sun, 4 Jul 2010, Michael Stapelberg wrote:

> Hi,
> I recently wanted to convert i3lock (a simple screen locker forked from slock)
> to use XCB. One of the features of i3lock is to display an image instead of
> only a black screen (like slock). At the moment, we do this using libXpm for
> simplicity.
> Because libxpm requires xlib, I canÿÿt use it with xcb. So I looked into
> directly using libjpeg and/or libpng, but it seems very complicated (multiple
> pages of code to load an image while i3lock has only ~ 250 SLOC). Also, I
> looked into imlib2, but it also does not work with xcb (because you need the
> xlib Display and Visual data structure for imlib_context_set_visual()).

it reminds me that i should port imlib2 to xcb...

> My question is: What is the best way (not much code, no strange dependencies)
> to load an image in a relatively convenient format (jpeg/png) when using XCB?

it's not really an XCB related question : all you have to do is getting 
the (A)RGB data from your image file and putting it in, for example, an 

So it depends on what you want:

1) A full framework, using XCB, which will read / decompress your image 
file to something that suits your needs

2) or just some code that read / decompress the image file, and after 
that, you put the data in an xcb_image



More information about the Xcb mailing list