[Xcb] Displaying DIBs using xcb-util/xcb

Jeetu Golani jeetu.golani at gmail.com
Sat Jul 18 11:38:36 PDT 2009

Thank you so much Peter :)....makes better sense now and yes the xli source 
code is definitely interesting :)

On Friday 17 Jul 2009, Peter Harris wrote:
> Jeetu Golani wrote:
> >> XCB/util does provide image conversion helpers that will change depth
> >> and swap byte orders as necessary. What it does not do is handle any
> >> sort of palette (depth 4 or depth 8 DIBs drawn onto a TrueColor
> >> screen, or TrueColor DIBs drawn to a PseudoColor screen).
> >
> > Would appreciate if you could tell me which helper functions would help
> > me change depth and swap byte orders.
> >
> > Is there an example someone could point me towards using the
> > xcb_create_pixmap_from_bitmap_data function?
> You don't want xcb_create_pixmap_from_bitmap_data unless your DIB is
> depth-1 (bitmap always means 1-bit in X speak; we use pixmap if there
> are more colours).
> Instead, you probably want xcb_image_create to create an xcb_image_t
> with your particular format, and xcb_image_native to convert it to the X
> server's format.
> > The documentation suggests it needs the bitmap data in xbm format which
> > I'm assuming it needs a basic header of width height followed by bitmap
> > data.
> Actually this function creates the header from the width and height you
> pass in (and assumes LSByteFirst, LSBitFirst, 8-bit unit, 8-bit
> padding). The data block is just the raw image bits.
> Same for xcb_image_create (except without the assumptions; you have to
> pass in your bit order, byte order, etc, in addition to width and height).
> For a (relatively slowly executing) example, you could look at
> test_formats.c in the xcb/util source tree.
> I note that xcb/util does not support RGB mask conversion. Contributions
> in this area would be much appreciated.
> > Would appreciate if someone can give me more information of this format
> > for colour pixmaps say 32bpp. I also wonder that in a DIB information is
> > stored in the order Blue, Green, Red intensities....
> Not always. (See BI_BITFIELDS in the DIB docs)
> > is it the same for an X Pixmap
> > or is it reversed?
> It is the same (ie. it is not always RGB or BGR - it can be either, so
> you have to support conversion).
> > Since I don't need any hard core conversion between different formats and
> > simply want to display a DIB to X using XCB I'm averse to using
> > ImagicMagick or a complex library.
> DIBs really are complex. They can even contain compressed data (PNG or
> JPEG) sometimes. If you "just" want to display a DIB using XCB, you
> probably want to narrow your requirements to "Just display TrueColor
> BI_RGB DIBs to TrueColor X servers".
> > I'll go through the xli software though I think it
> > would rely on xlib and I wonder if the format used would be different
> > than what the xcb/xlib functions would use.
> Xlib and xcb use the same formats. xcb_image_create_native should take
> data in the same format as XCreateImage.
> Peter Harris

More information about the Xcb mailing list