Search code examples
imagescreenshotx11xcb

Get a 24-bit screenshot with XCB-SHM


Is there any way to get a 24-bit BGR ZPixmap from xcb_shm_get_image? All I can seem to get are 32-bit BGRA images, and that alpha channel seems really unnecessary. Editing the bitmask to exclude the alpha doesn't work, it only sets it to zero.


Solution

  • Well, for convenience 32 bits are always used when dealing with 24 bit color spaces. A CPU is much more efficient at handling 4 bytes at a time... The 'wasted' alpha byte is a good tradeoff between efficiency and memory consumption. So just copy the data yourself, packing the RGB bytes into 3 bytes per pixel.