Well if you've searched the XLib API for something to do it, and found nothing, then you're going to have to write to code yourself (or find some standalone code to adapt for your use).

Here's the...